Formatting the Windows date in a filename.
I’ve often needed to date an output file or backup folder created from a Windows script. The %DATE%
variable cannot be used on it’s own because it returns a value with slashes in.
This method formats it to the ISO standard YYYYMMDD
1echo %date:~6,4%-%date:~3,2%-%date:~0,2%
22012-05-16
Example- Backing up files to a dated folder
1robocopy "C:\My Source Documents\" "D:\My Backup Documents\%date:~6,4%-%date:~3,2%-%date:~0,2%\" /MIR