When you want to use the current date as a part of a file's name, you want to see something like '01012011'. Usual 'date' variable gives you human-readable date with additional dots looking like this: '01.01.2011'. Or something like this: '01/01/2011'. It depends on the settings of your copy of Windows. Fortunately, it is not hard to remove unnecessary characters from the string with the date. All you need to do is to use the following construction:
echo %date:.=%
This code will remove dots from the string with the current date. Can you consider the string that allows you to remove slashes?..
echo %date:.=%
This code will remove dots from the string with the current date. Can you consider the string that allows you to remove slashes?..
set d1=%date:~0,2%
ReplyDeleteset d2=%date:~3,2%
set d3=%date:~6,4%
SET DATE2=%d1%_%D2%_%D3%
Even easier....
ReplyDeleteset DATE2=%date:~0,2%_%date:~3,2%_%date:~6,4%
But it does not simply need to search for the slash to remove instead of dot?, like:
ReplyDeleteecho %date:/=%
in win7 and xp works.
echo %date:/=% Worked for me.
ReplyDelete--admin @ od46.com