Rename File with Timestamp in 24hrs
|
Original Message
|
Name: mafl
Date: November 26, 2003 at 12:03:24 Pacific
Subject: Rename File with Timestamp in 24hrs OS: NT 4.0 CPU/Ram: intel
|
Comment: I need to rename a file appending the timestamp of the system in this format: yyyymmddhhmmss Example: convert crexp.txt to crexp20031126144543.txt I was using this: for /f "tokens=2-4* delims=/ " %%a in ('DATE /T') do set THEDATE=%%c%%b%%a for /f "tokens=1* delims=: " %%a in ('time /T') do set THETIME=%%aa%%bb%%cc%%dd ren %1 %~n1%THEDATE%%THETIME%%~x1 however this does not give hours in 24hrs format, nor does it give me seconds
Report Offensive Message For Removal
|
|
Response Number 2
|
Name: mafl
Date: November 26, 2003 at 13:21:08 Pacific
|
Reply: (edit)the output of C:\>Command /C Ver | Time The current time is: 16:20:49:84 Enter the new time: Incorrect MS-DOS version The system cannot accept the time entered. Enter the new time: C:\>
Report Offensive Follow Up For Removal
|
|
Response Number 3
|
Name: IVO
Date: November 26, 2003 at 13:47:08 Pacific
|
Reply: (edit)The output I expected is The current time is: 16:20:49:84 Enter the new time: neater than you posted. However try to replace your previous for /f "tokens=1* delims=: " %%a in ('time /T') do set THETIME=%%aa%%bb%%cc%%dd ren %1 %~n1%THEDATE%%THETIME%%~x1 with the following For /F "tokens=2-4 delims=:" %%a in ('Command /C Echo. ^| Time ^| Find "current"') Do Set THETIME=%%a%%b%%c Set THETIME=%THETIME:~1% ren %1 %~n1%THEDATE%%THETIME%%~x1 If anything goes, wrong post again.
Report Offensive Follow Up For Removal
|
|
Response Number 4
|
Name: mafl
Date: November 28, 2003 at 06:48:34 Pacific
|
Reply: (edit)What I am supposed to get with your suggestion above? so far I have entered the command as it is above, tweaked it in all manners and I always get error messages: like syntax error, /c is not a recognized internal o external command, etc.
Report Offensive Follow Up For Removal
|
|
Response Number 5
|
Name: IVO
Date: November 28, 2003 at 07:14:20 Pacific
|
Reply: (edit)The statement beginning For /F ends on the third line with %%a%%b%%c without new lines between. I suggest you highlight, copy and paste into your NotePad the lines I posted to be sure to get them integer. The statement must work in a batch file. Report to me what's the result.
Report Offensive Follow Up For Removal
|
|
Response Number 6
|
Name: mafl
Date: December 1, 2003 at 10:52:20 Pacific
|
Reply: (edit)Your suggestion work fine. I just made some adjustments to substring the output. The problem was that I got confused with the circumflex accents before the pipe command. I took out this and it work all fine. Thanks,
Report Offensive Follow Up For Removal
|
Use following form to reply to current message: