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!!!
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]
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
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
posted by harkin banks at 1:55 PM on December 20, 2007
This thread is closed to new comments.
posted by cerebus19 at 8:06 AM on December 20, 2007