Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
I need a batch file to copy files from 1 location to another on a network daily. The only problem I have is I dont know the exact folder the files are in as they is generated randomly. The folder containing the files would be in the format "Quote_YYMMDD_*****" Where the YYMMDD is obv yearmonthday and the * represents a number. The date is always todays, and the digits are completely random.
The filename is batch.log, and always will be. If poss, I need this to become batchyymmdd*.log in its new location, where the * is a letter. This is because there may be more than one file created each day. I am not really too used to working with batch files so any help would be great.
What I have is the following but I am having no luck. Only one batch.log exists in any one folder.
set yy=%date:~12,2%
set mm=%date:~7,2%
set dd=%date:~4,2%copy "\\apdprint\JFormDatsBackUp\Quote_%yy%%mm%%dd%_*****\batch.log" \\apdfile001\users\motorfollowups\batch%yy%%mm%%dd%.log
Sorry for rambling a bit, if you need any further info let me know. Would be looking at running this overnight to capture 2 or 3 instances

I don't know about the \\ and I'm not quite sure where we're going with the naming, but see if this makes sense for a start.
::###
@echo offcd \apdprint\JFormDatsBackUp
dir /ad/b quote* > dirLIST
for /f "tokens=*" %%D in (dirLIST) do call :copier %%D
goto :eof:copier
copy %1\batch.log
::###
If at first you don't succeed, you're about average.M2

It is very unusual to have a program generate a file in a random location and with a partial random name. I would fix the log generating program first and then a simple copy would work. The generating program should be the one to label the daily batches.

The \\ is basically because the folder is on a network drive, apdprint being the server.
The file is not actually generated in a random location, the ***** is sequential, just that Quote is not the only print job that creates a folder so we have a situation such as the following folders being generated.
Quote_051109_12345
HouseMTA_051109_12346
Renewal_051109_12347
Quote_051109_12348There is about 25 different types of print run, so I have no idea when quote shows up, which is why I say random. So what I would want to happen is the batch.log file to be taken from Quote_051109_12345, and put into motorfollowups on the other server as batch051109A.log. Then the batch.log from Quote_051109_12348 saved into motorfollowups as batch051109B.log.
Is the network drive situation a problem? I know Im not the best at explaining these things, but batch programming really isn't my thing at all, so Im not sure on its limitations. If it cannot be done by batch files, I can look at alternative methods

![]() |
![]() |
![]() |

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |