Help with a batch file?
December 20, 2007 7:55 AM   Subscribe

windowsbatchfile: Can someone give me the command/script for a simple batch file that will take a file from location A, copy it to location b, then add the current date to the name of the file> Thanks in advance!!!
posted by flipmiester99 to Computers & Internet (4 answers total)
I know this could be done with a batch, but wouldn't it be easier to use a freeware utility (use the /C option to copy instead of rename)?
posted by cerebus19 at 8:06 AM on December 20, 2007

Will the name of the file you're copying always be the same? If so, I do this with my spam logs using a batch file which Scheduled Tasks runs nightly (the program won't keep a log beyond yesterday on its own).

cd E:\Applications\No Spam Today!
copy noSPAMtoday.log~ e:\NSTlog
cd e:\NSTlog
ren noSPAMtoday.log~ test%date:~4,2%-%date:~7,2%-%date:~10%.txt

This renamed yesterday's log file from noSPAMtoday.log~ to test12-19-2007.txt
posted by jmd82 at 8:06 AM on December 20, 2007 [1 favorite]

You don't need a batch script for this, it's just a single line. You could save it as a batch file if you wanted I guess...

copy directory_a\doc.txt directory_b\doc%date:~4,2%-%date:~7,2%-%date:~10%.txt
posted by sprocket87 at 9:59 AM on December 20, 2007

The solutions that jmd82 and sprocket87 gave won't work if a) you are using Windows 98 or something pre-NT, or b) if your computer is set to use something other than the standard US-ian date format. If neither of those are true, then you should be fine.
posted by harkin banks at 1:55 PM on December 20, 2007

« Older Come on Down!   |   Mismarried Mac, Mac, Mac Newer »
This thread is closed to new comments.