DOS: Backing up files to datestamped version

cd r:mtpgtd
rem
rem Get the date – returns 2005 1110
for /f “tokens=1,2,3 delims=/ eol= ” %%I in (‘date /t’) do set sdate=%%K%%J%%I

rem
rem Strip out the space
for /f “tokens=1,2” %%I in (‘echo %sdate%’) do set sdate=%%I%%J

rem
rem Copy the files to old/
for /f %%I in (‘dir /b *.txt’) do copy %%I old\%sdate%_%%I

Advertisements