I have figured out how to rename a file with the date using the command
below:
ren test.txt test_%date:~10,4%-%date:~4,2%-%date:~7,2%.txt
Example: test.txt to test_2004-11-04.txt
However I would also like to rename a file with the time. Does anyone have
any suggestions?
Use #LogDate and #LogTime from the Advanced NT/2K/XP/K3 Command Library.
It's FREE and performs CONSISTENTLY across all four platforms.
#LogDate is always yyyymmdd
#LogTime is always hhnnss
*******
1. CALL ntlib.cmd /Init /Quiet
2. REN "test.txt" "test_%#LogDate%-%#LogTime%.txt"
*******
For more info about #LogDate and #LogTime, including color-keyed examples,
see
(
http://TheSystemGuard.com/MtCmds/GetValue/GetLogDate.htm)
(
http://TheSystemGuard.com/MtCmds/GetValue/GetLogTime.htm)
For cross-platform help on internal commands CALL and REN
(
http://TheSystemGuard.com/TheGuardBook/CCS-Int/CALL.htm)
(
http://TheSystemGuard.com/TheGuardBook/CCS-Int/REN.htm)
To request your FREE copy of the Advanced Command Library, go to
(
http://ntlib.com).
*******
The Command Library is constructed using ONLY builtin
commands common to all four platforms (NT/2K/XP/K3).
There is NO BINARY CODE. This is a single .cmd file,
optimized and compressed with full documentation.
-tsg
/-----------------+---------------+----------------------\
| COMPATIBILITY | CLARITY | SPEED |
| Write code ONCE | Make it clear | THEN...Make it fast! |
\-----------------+---------------+----------------------/
400+ command-line resources using ONLY native NT commands!
(
http://TheSystemGuard.com/default.asp#MasterCommandList)