Discussion Locked

Simple file rename script with date

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

I am new to scripting and am in need of a simple script to rename or copy a file from a constant file name to a date file name. IE: score01.txt to 101701.txt (todays date)
this is for a daily process. I couldn't find a way in a batch file to do this. I am assuming it would be very easy in a vbscript file or something. It will be running on an NT4.0 box.

3 replies

by jay eckles

Save the following in a .bat file and run it in the same directory as the one in which score01.txt resides. It works on my NT 4 machine.

::RenameToDate.bat
::by Jay Eckles - www.jayeckles.com

::set CURDATE to current date in MMDDYYYY formatFOR /f "tokens=2-4 delims=/ " %%a in ('DATE/T') do SET CURDATE=%%a%%b%%c

::rename score01.txt to MMDDYYYY.txt
rename score01.txt %CURDATE%.txt

This discussion is closed to new replies.