Skip to content.

TalkBMC

Sections

Comment

Above in this comment thread: MS-DOS tips for time and date stamps

help

Posted by MOFO at 2007-05-08 08:30
How can i edit this code to make it time-stamp a folder in this format: YYYY-MM-DD_HH.MM.SS
Ex. 2007-05-08_05.30.12

just a few modifications... 12,4 is key here for the YYYY

Posted by Anne Gentle at 2007-05-08 14:17
The way to get a four-digit year is to change the second value when extracting the year variable. After getting the four-digit year value, you can just insert dashes and periods. So this should work:

set hh=%time:~0,2%
if "%time:~0,1%"==" " set hh=0%hh:~1,1%
set yyyy-mm-dd_hh.mm.ss=%date:~12,4%-%date:~4,2%-%date:~7,2%_%hh%.%time:~3,2%.%time:~6,2%
md c:\temp\%yyyy-mm-dd_hh.mm.ss%

Thanks everyone for the appreciation for this code! In turn I appreciate our expert Search Engine Optimizer, Tom Parish, for making this page a high hit in Google searches for dos date searches. :)

DOS time stamp YYYY

Posted by Ann Vrbancic at 2007-10-10 15:39
The trick to get YYYYMMDD format is
set FileName=%date:~10,4%%date:~4,2%%date:~7,2%

that is 10,4 not 12,4
 
 

Powered by Plone

This site conforms to the following standards: