This can be run or called by: “datename.bat log.txt” which will rename “log.txt” to “200804100945AM.log.txt”
——–datename.bat———-
@Echo OFF
TITLE DateName
REM DateName.CMD
REM takes a filename as %1 and renames as YYMMDDHHMM_%1
REM
REM ————————————————————-
IF %1.==. GoTo USAGE
Set CURRDATE=%TEMP%\CURRDATE.TMP
Set CURRTIME=%TEMP%\CURRTIME.TMP
DATE /T > %CURRDATE%
TIME /T > %CURRTIME%
Set PARSEARG=”eol=; tokens=1,2,3,4* delims=/, ”
For /F %PARSEARG% %%i in (%CURRDATE%) Do SET YYYYMMDD=%%l%%k%%j
Set PARSEARG=”eol=; tokens=1,2,3* delims=:, ”
For /F %PARSEARG% %%i in (%CURRTIME%) Do Set HHMM=%%i%%j%%k
Echo RENAME %1 %YYYYMMDD%%HHMM%_%1
RENAME %1 %YYYYMMDD%%HHMM%_%1
GoTo END
:USAGE
Echo Usage: DateName filename
Echo Renames filename to filename_YYYYMMDDHHMM
GoTo END
:END
REM
TITLE Command Prompt