Computing.Net > Forums > Programming > Rename *.TXT file with 24 Hour Time Stamp

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Rename *.TXT file with 24 Hour Time Stamp

Reply to Message Icon

Name: DealMaker
Date: August 4, 2009 at 02:26:28 Pacific
OS: Windows 2003
Subcategory: Batch
Comment:

Hello,

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?

Thanks,

Brett



Sponsored Link
Ads by Google

Response Number 1
Name: Mechanix2Go
Date: August 4, 2009 at 03:10:05 Pacific
Reply:

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.

M2


0
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: Rename *.TXT file with 24 Hour Time Stamp

Rename a file with time www.computing.net/answers/programming/rename-a-file-with-time/11595.html

Newbie... Batch file creation? www.computing.net/answers/programming/newbie-batch-file-creation/17499.html

batch to rename txt file using data inside www.computing.net/answers/programming/batch-to-rename-txt-file-using-data-inside/19709.html