Batch File

By jbuytendorp ·
I am working in a Windows XP environment. I have a *.cmd file that somebody else created to ftp a bunch of files to a different server. I need to change the name of the file to include a time stamp on the end of the file name.
The original file names looks like this (they are stored in one directory):


(the date and time of the file creation is at the end).
I need to drop the last 6 characters, the time, and add the current time to the end of the file. The current time being when the cmd file to ftp the files is run. I have the cmd file setup to run from a scheduled task.

This conversation is currently closed to new comments.

Thread display: Collapse - | Expand +

All Answers

Collapse -

I usually

by Dr Dij In reply to Batch File

have a VB program create a text file named .bat and also the .cmd files, I add the date from VB to the file name and print it out to the .cmd file. Then I call the .bat I just created to start FTP with the .cmd file I also created as parameter.

I also log file names in a database table so I don't run the same file twice.

Collapse -

Thanks for the reply

by jbuytendorp In reply to I usually

Actually a stored procedure is creating the files and naming them just like you suggested. But two different procedures create the files so the timing of the files is just a few seconds off. The times in the file name need to be changed to when they are being FTP'd. So I think that the best way to do this would be when the cmd file is run via the stored proceedure.

Collapse -

I'd modify the procedure

by TonytheTiger In reply to Thanks for the reply

to NOT put the time in the filename, then in the batch file you can create a newtime string

FOR /F "tokens=1-3 delims=:." %%I IN ("%time%") DO SET newtime=%%I%%J%%K

and rename the files to include this string (newtime) at the end.

Related Discussions

Related Forums