Question Locked

Batch File

0 helpful
4 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

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):

file_XX25_20080619_143000.dat
file_XX26_20080619_143000.dat
file_XX27_20080619_143000.dat

(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.

4 replies

by dr dij

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.

by jbuytendorp

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.

by tonythetiger

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.

This discussion is closed to new replies.