How can I create / name a folder with today’s date?

This is very handy if you are using scripts to generate daily logs and would like to put them in a folder with the current date. You can, of course, tweak the commands to suit your requirements:

 

for /F “tokens=1-4 delims=/ ” %%A in (‘date /t’) do (
set DateDay=%%A
set DateMonth=%%B
set DateYear=%%C
)

set CurrentDate=%DateDay%-%DateMonth%-%DateYear%

md %CurrentDate%

This will give you a newly created folder with today’s date, in the format of DD-MM-YY

One Response to How can I create / name a folder with today’s date?

  1. Hi, I am not a programmer and wanted to use this code, but how I could incorporate in on my windows command (right click, etc). Thanks

Leave a Reply

Your email address will not be published. Required fields are marked *