I have the below code to copy all PDFs from drive C: to drive D:.
#ECHO OFF
COPY "C:\testing\*.pdf" "D:\testing2\*.pdf"
I only want to copy the latest PDF.
What do I need to copy only the files with last modification date equal today´s data?
Related
I am using PDFtk-server to merge 2 PDF files. This creates a new PDF with name Test_.
Now, what I am looking for is a batch files that renames the Test_ files to Test_datestamp and then move them into another folder and delete the files.
It is working if only one file is present.
pdftk C:\test\*.pdf C:\test\file-to-add\file.pdf cat output C:\test\output\Test_.pdf
ren "C:\test\output\*pdf" "Test_ - %date:/=.% %time::=-%.pdf"
del C:\test\*.pdf
Then comes to copy part to other folders.
If having multiple files, the first one gets renamed but other not, because it is trying to set the same timestamp, so I need some kind of delay between renaming.
I have been able to copy files from 1 location to another using the batch file.
However I need to copy the complete folder from one server to multiple servers.
Example;
Local machine name :
LOCAL
Destination machines :
Network1
Network2
folder that i need to copy
Local\d:\Hello
The whole folder hello and its contents to be copied
to
Network1\c
Network2\c
So the folders thats created should be like (with all the file within)
Network1\c:\Hello
Network2\c:\Hello
Looks like you might want to use xcopy. See below;
batch/bat to copy folder and content at once
You should end up with a script like this;
xcopy d:\Hello \\Network1\c$\ /E
xcopy d:\Hello \\Network2\c$\ /E
I would like to create a batch file to copy *.EXT files to the destination folder with appended date and time to file name and copy upto maximum 30 files. After 30 files are copied, should delete oldest file. (while copy the 31st file, the 1st file should be deleted, and so on).
Thanks for your support. Have a great day!
I am new to this , Actually my requirement is to take backup of some XML file from one machine to another machine .So my senario would be when i click on the batch file it will create a new folder on the second server (name of the folder should be date and time )and under this folder it paste all the copied files .
I need to create a new folder every time as i am doing version control.
Thanks
VG
The batch file is very simple
#echo off
setlocal
set "copydest=%date%_%time%"
for %%i in (/ - : .) do call set "copydest=%%copydest:%%~s=%%
xcopy "c:\path\to\your\datafiles\*.xml" "c:\parent\%copydest%\"
which should copy the .xml files from the directory c:\path\to\your\datafiles\ to a new directory under c:\parent\which has the date/time as its name.
The precise structure of that date/time depends on your settings. If you don't tell us what your settings are, we'd have to write a book about all of the possible combinations - not going to do that.
The for %%i... line does the removal of the common date/time separators; of these : and / are the important ones since they are invalid in a filename.
I need to copy files from one machine to my local disc using batch commands.
My files contain the date in dd-mm-yyyy format. But in case if i am using this:
-%date:/=-%
it is interpreted as "day" and then date which is not really associated with my file name at the source end.
Once I click my bat file it will copy one folder say "xyz dd-mm-yyy" I want to copy only today's folder as on my source machine saved last 7 days folder.
EDIT: my folder name on source machine is Site_info 11-07-2011 and tomorrow one more folder will get added to the same machine with name site_info 12-07-2011. I want to run the bat file machine where it will copy only today's folder.
EDIT2: Thanks for kind support still i am not able to achieve my target.If possible please provide the commands for following situation
My machine path :c:\Documents and Settings\user1\Desktop\SITE_INFO\Site_info 12-07-2011 where Site_info 12-07-2011 will change to site_info 13-07-2011
Source address :- \97.253.72.127\Cdma Site_info\Site_info 12-07-2011 Tomorrow one more folder will get add on this path with dated like \97.253.72.127\Cdma Site_info\Site_info 13-07-2011
If you mean that there's the 'day of week' part preceding the date and you want to get rid of that part, then you'll probably need an additional variable. First you'll cut off the day of week, then replace / with -, like you are already doing. It might be something like this:
…
SET "dateonly=%date:~4%"
SET "dateonly=%dateonly:/=-"
…
COPY \\computer\share\path\whatever-%dateonly%.ext drive:\path\%dateonly%\
…
You could try to puzzle the date the way you want it:
set mydate=%date:~-10,2%-%date:~-7,2%-%date:~-4%
xcopy /E /I "Site_info %mydate%" "Copy\Site_info %mydate%"