Computing.Net > Forums > Programming > Batch file help needed

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Batch file help needed

Reply to Message Icon

Name: Riddler83
Date: November 8, 2005 at 09:28:09 Pacific
OS: Windows 2000
CPU/Ram: 512
Comment:

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



Sponsored Link
Ads by Google

Response Number 1
Name: Mechanix2Go
Date: November 8, 2005 at 10:02:07 Pacific
Reply:

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 off

cd \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


0

Response Number 2
Name: wizard-fred
Date: November 8, 2005 at 11:37:38 Pacific
Reply:

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.


0

Response Number 3
Name: Riddler83
Date: November 9, 2005 at 01:53:57 Pacific
Reply:

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_12348

There 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


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More







Post Locked

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


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: Batch file help needed

DOS Batch File Help? www.computing.net/answers/programming/dos-batch-file-help/15613.html

Batch File Help, 'delete all folder www.computing.net/answers/programming/batch-file-help-delete-all-folder/13383.html

batch file help www.computing.net/answers/programming/batch-file-help/16293.html