Computing.Net > Forums > Programming > Rename a file with time

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 a file with time

Reply to Message Icon

Name: David Terrill
Date: November 3, 2004 at 16:44:46 Pacific
OS: Windows 2000
CPU/Ram: 2 Ghz
Comment:

I have figured out how to rename a file with the date with the command below:
ren test.txt test_%date:~4,2%-%date:~7,2%-%date:~10,4%.txt

However I would also like to rename a file with the time. Does anyone have any suggestions?



Sponsored Link
Ads by Google

Response Number 1
Name: Mechanix2Go
Date: November 3, 2004 at 22:45:24 Pacific
Reply:

You're on the right track.

I guess you tried an appraoch similar to you date namer, but it did not work.

You can use %TIME% as is ONLY IF it has no colons, backslashes or other no-go filename chars.

If it does, you have two choices. Re-do the time format in control panel. Or use some substring grabs as you did with DATE.

HTH

M2


0

Response Number 2
Name: David Terrill
Date: November 4, 2004 at 19:47:42 Pacific
Reply:

I found it!!!!

ren test.txt test_%time:~0,2%%time:~3,2%.txt
result: test_2241.txt (2241=10:41 PM)


0

Sponsored Link
Ads by Google
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 a file with time

Rename *.TXT file with 24 Hour Time Stamp www.computing.net/answers/programming/rename-txt-file-with-24-hour-time-stamp/19772.html

Help needed renaming a file in DOS www.computing.net/answers/programming/help-needed-renaming-a-file-in-dos/12770.html

Batch file to rename a file www.computing.net/answers/programming/batch-file-to-rename-a-file/14356.html