WatchDirectory Forum
http://www.watchdirectory.net/cgi-bin/yabb25/YaBB.pl
watchDirectory forums >> How to... >> Copy file to another dir and rename with date/time
http://www.watchdirectory.net/cgi-bin/yabb25/YaBB.pl?num=1108379701

Message started by mikehoot2020 on Feb 14th, 2005 at 12:15pm

Title: Copy file to another dir and rename with date/time
Post by mikehoot2020 on Feb 14th, 2005 at 12:15pm
Hi

I need to monitor a directory and when a file arrives (every hour) I need to take a copy to another directory and rename it to include a date and time stamp.

If anyone could point me in the right direction I would be very grateful as I am new to this program.

Monitored Dir:   D:\INTERFACE

Filename (always the same)   JACPAS.DAT

Copy to Dir:   D:\INTERFACE\ARCHIVE

Rename file like:   20041402_1108_JACPAS.DAT

Thanks

Mike

Title: Re: Copy file to another dir and rename with date/
Post by Gert on Feb 14th, 2005 at 12:38pm
Hello Mike,

That should be easy enough. I suggest you use the wdautocopy.bat sample.

Find the line that reads

Code (]COPY "%WD_FILE%" "%TARGETDIR%"[/code):

and change that to
[code]COPY "%WD_FILE%" "%TARGETDIR%\%WD_DATE%_%WD_TIME%_%WD_FILE_N%"


WD_DATE contains the date of the event (YYYYMMDD format)
WD_TIME has the time (HHMMSS)
WD_FILE_N contains just the name of the file (without directory), in your case JACPAS.DAT

Other %variables% you can use are explained here:
http://www.watchdirectory.net/watchDir/help/bat.html

Gert

Title: Re: Copy file to another dir and rename with date/
Post by mikehoot2020 on Feb 16th, 2005 at 1:24pm
Perfect!

Works great and just what I was looking for.

I think you may have earned a sale on this script alone!

Thanks

WatchDirectory Forum » Powered by YaBB 2.5.2!
YaBB Forum Software © 2000-2017. All Rights Reserved.