Rename *.TXT file with 24 Hour Time Stamp

August 4, 2009 at 02:26:28
Specs: Windows 2003

I am trying to create a batch file which will rename *.TXT files with the current time. The command below works perfectly when the time is betwenn 10am and 12:59am but does work when the time is beween 01:00 and 09:59. Any idea's why? The command I am using is below:

ren *.txt txt_%time:~0,2%%time:~3,2%.txt

If I was to run the command now it would work and rename the text file as txt_10:25.txt.

Any suggestions on why it does not work between the hours of 01:00 - 09:59?



See More: Rename *.TXT file with 24 Hour Time Stamp

Report •

August 4, 2009 at 03:10:05
Probably because at 01:00 the leading zero is not there so instead of 01 you get 1: or other gibberish depending on your settings.

If at first you don't succeed, you're about average.


Report •
Related Solutions

Ask Question