I need to automate the following process:
A Crystal report is run on a monthly basis which creates the following file each month:
sls316_2015-01-06-04-12-37.pdf where 2015-01-06-04-23-37 is the date-time the pdf file was created.
Each month the date time changes and I need a batch script to copy this file to another directory.
Can I automate this with a .bat file?
Thanks.
Mark
Copy files with dynamic names
Moderator: DosItHelp
Re: Copy files with dynamic names
Well this could be approached a couple of different ways but really need more information.
1) Are you just trying to synchronize two folders for backup purposes. The PDF should exist in both folders.
or
2) Will this be the only PDF in the folder that needs to be copied and then it is deleted from that original location?
or
3) Does the file name always start with sls316?
1) Are you just trying to synchronize two folders for backup purposes. The PDF should exist in both folders.
or
2) Will this be the only PDF in the folder that needs to be copied and then it is deleted from that original location?
or
3) Does the file name always start with sls316?
-
- Posts: 9
- Joined: 13 Jan 2015 09:51
Re: Copy files with dynamic names
Just copying .pdf files from a report server to a shared network drive. The timestamp is written into the file name and
only need to copy the latest dated file. There will be several files that need to be copied like this but if you could show me an
example for 1 I could do the others.
only need to copy the latest dated file. There will be several files that need to be copied like this but if you could show me an
example for 1 I could do the others.
Re: Copy files with dynamic names
Could you please answer question 3.
Re: Copy files with dynamic names
If you want the newest PDF file in the directory you can do this.
Code: Select all
FOR /F "delims=" %%G in ('dir *.pdf /a-d /b /od') do set "newest=%%~G"
copy "%newest%" "X:\path to some folder\"
-
- Posts: 9
- Joined: 13 Jan 2015 09:51
Re: Copy files with dynamic names
Squashman,
Thank You very much, that worked perfectly.
Mark
Thank You very much, that worked perfectly.
Mark