4 replies
by syscokid
This code will add the current date to the name of the file:
REM file_rename.bat
@echo off
cls
echo.|date /t >holdstr
for /f "tokens=2,3,4*" %%a IN (holdstr) do echo %%a%%b%%c >holdstr
for /f "tokens=1 delims=/" %%a IN (holdstr) do set month=%%a
for /f "tokens=2 delims=/" %%a IN (holdstr) do set day=%%a
for /f "tokens=3 delims=/" %%a IN (holdstr) do set year=%%a
set day=%day:~0,2%
set year=%year:~0,4%
if %month%==01 set month2=Jan
if %month%==02 set month2=Feb
if %month%==03 set month2=Mar
if %month%==04 set month2=Apr
if %month%==05 set month2=May
if %month%==06 set month2=Jun
if %month%==07 set month2=Jul
if %month%==08 set month2=Aug
if %month%==09 set month2=Sep
if %month%==10 set month2=Oct
if %month%==11 set month2=Nov
if %month%==12 set month2=Dec
REM ** NOW, rename your file. I did not specify a specific drive and directory.
REM ** So, run this in the current directory OR include the proper path
ren yourfile.txt yourfile%day%%month2%%year%.txt
del holdstr
set day=
set month=
set year=
by michelle
by michelle
by michelle
This discussion is closed to new replies.
Trending Web Development posts
Sort by Trending