Skip to content.

TalkBMC

Sections
You are here: Home » Blog Archive » Anne Gentle » Exploring Information Design and Development » Need to make sure you use %hh%

Comment

Above in this comment thread: MS-DOS tips for time and date stamps » MS-DOS Tips for Time and Date Stamps

Need to make sure you use %hh%

Posted by Anne Gentle at 2006-06-05 11:46
Ah, it took me a little while, but I just realized that you're still using %time:~-11,2% instead of substituting %hh% in the final rename command.

This should work:

set hh=%time:~0,2%

REM Since there is no leading zero for times before 10 am, have to put in

REM a zero when this is run before 10 am.

if "%time:~0,1%"==" " set hh=0%hh:~1,1%

set yyyymmdd-hhmmss=%date:~-4,4%%date:~-10,2%%date:~-7,2%-%hh%%time:~-8,2%%time:~-5,2%

ren dtfile1.txt DATA-%yyyymmdd-hhmmss%.txt

Not appending timestamp to filename

Posted by Raul at 2007-12-07 23:57
I tried this script and even though it's renaming the original .txt file it's not appending the timestamp to the file name. I'm getting something like:

Test-.txt instead of Test-<timestap>.txt so, obviously when I run the bat file again I get a cmd error
 
 

Powered by Plone

This site conforms to the following standards: