Categories
Geeky

Date as string in DOS batch files

Thanks to Peter from Cedes, who found that on the great big world wide web. Ever needed to build filenames in DOS/Windows Command Line Prompt in batch files, which consists of the actual date? No problem to do that with a bash, but DOS? Here is how to do that.

Following string will be shown as: filename_2008_29_08.ext

set varname=filename_%Date:~-4,4%_%Date:~-10,2%_%Date:~-7,2%.ext

Must be something like internal substring handling or so.