Ah, it took me a little while, but I just realized that you're still using %time:~-11,2% instead of substituting %hh% in the final rename command.
This should work:
set hh=%time:~0,2%
REM Since there is no leading zero for times before 10 am, have to put in
REM a zero when this is run before 10 am.
if "%time:~0,1%"==" " set hh=0%hh:~1,1%
set yyyymmdd-hhmmss=%date:~-4,4%%date:~-10,2%%date:~-7,2%-%hh%%time:~-8,2%%time:~-5,2%
ren dtfile1.txt DATA-%yyyymmdd-hhmmss%.txt
Not appending timestamp to filename
Posted by
Raul
at
2007-12-07 23:57
I tried this script and even though it's renaming the original .txt file it's not appending the timestamp to the file name. I'm getting something like:
Test-.txt instead of Test-<timestap>.txt so, obviously when I run the bat file again I get a cmd error
This should work:
set hh=%time:~0,2%
REM Since there is no leading zero for times before 10 am, have to put in
REM a zero when this is run before 10 am.
if "%time:~0,1%"==" " set hh=0%hh:~1,1%
set yyyymmdd-hhmmss=%date:~-4,4%%date:~-10,2%%date:~-7,2%-%hh%%time:~-8,2%%time:~-5,2%
ren dtfile1.txt DATA-%yyyymmdd-hhmmss%.txt
Test-.txt instead of Test-<timestap>.txt so, obviously when I run the bat file again I get a cmd error
Replies to this comment