Create a date and time stamped folder from dos cmd prompt

ok so you need to create a directory based on the current time and date, a timestamp if you will.

its easy, type this into your cmd window …

mkdir %date:~-4,4%%date:~-7,2%%date:~0,2%-%time:~0,2%%time:~3,2%%time:~6,2%

this will give you a directory named like YYYYMMDD-HHMMSS

Enjoy.

3 Responses to “Create a date and time stamped folder from dos cmd prompt”
programmer Posted on September 24, 2009 at 3:36 am

The sample produces an incorrect format like 2009ep4. Check your code please

jason.white Posted on October 7, 2009 at 6:08 pm

Hi Programmer, It works exactly as expected on Vista Ultimate and Win 2003 Server.. what are you running?

William Passino Posted on February 23, 2011 at 8:03 pm

Thanks for the example. Please note that the systems’ date/time format needs to be taken into consideration; easy to modify for that.

Post a Comment