I have used this many times to add a date in batch files. This example works for Windows batch files but can be adjusted for other uses.

You can set any variable, in my example below called “thedate” to a substring of the computers date to produce only the numbers without any “/” in case this needs to be used in creating folder or file names.

For my example I would like to use a script to create a photos folder with the date in the name:

set thedate=%date:~-4,4%%date:~0,2%%date:~-7,2%

then you can show your output

echo %thedate%

I then use

mkdir photos_%thedate%

to create a folder called “photos_20150727”

Date in windows batch files

The above was created using Window 7 but should work on Windows 10 as well..

Hope this helps. For some other tips using the command line see our list of other command line articles.