WatchDirectory Forum
http://www.watchdirectory.net/cgi-bin/yabb25/YaBB.pl
watchDirectory forums >> How to... >> How to add date to filename
http://www.watchdirectory.net/cgi-bin/yabb25/YaBB.pl?num=1093369744

Message started by MGarcia on Aug 25th, 2004 at 1:49am

Title: How to add date to filename
Post by MGarcia on Aug 25th, 2004 at 1:49am
I am trying to add, either by rename or copy, the date(mmddyyyy) to the filename once a static filename has been delivered to the directory Watchdirectory is monitoring.

Title: Re: How to add date to filename
Post by Gert on Aug 25th, 2004 at 2:18am
That shouldn't be to hard...

If you download our GdPUtil program (see http://www.gdps.dk/products/watchDir/GdPUtil.shtml) and use the following commands in your .bat file

Code (]C:\Bin\GdPUtil -datetime c:\temp\dt.bat
call c:\temp\dt.bat
del c:\temp\dt.bat
[/code):


you will have several date (and time) related variables available in your .bat file. One of them is DT_DATE that contains the current date (yyyymmdd format).

So, inside your .bat file, you could rename the new file like this:

[code]C:\Bin\GdPUtil -datetime c:\temp\dt.bat
call c:\temp\dt.bat
del c:\temp\dt.bat
REN "%WD_FILE%" "%WD_FILE_D%\%WD_FILE_B%.%DT_DATE%"

WD_FILE_D: the directory of the new file
WD_FILE_B: file name without extension

If you want it formatted like mmddyyyy, use %DT_MONTH%%DT_DAY%%DT_YEAR% instead.

In the above REN (rename) command, take care as it could 'fire' a new watchDirectory event. Perhaps it would be better to move or copy the file with the new extension to another directory.

Hope this helps,
Gert

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