|
Answer» Hi everybody. I Have 1 line for rename zip file every 5 minutes with this command :
c:\ren aaaa.zip %Date:~-4,4%_%Date:~-10,2%_%Date:~-7,2%_%Time:~-11,2%_%Time:~-8,2%_%Time:~-5,2%.*
Problem is, if current time < 10 am, batch file never run caused by result of "%Time:~-11,2%" only one digit ( 0, 1, 2 .. 9), other one digit will displayed as space, and rename command not run as well. This is sample result when batch file run at 9 am : "2005_12_29_ 9_54_18.*", You SEE, it should be "2005_12_29_09_54_18.*" to make it run well. Regional Setting - Time, set to hh:mm:ss tt, so every 9 am displayed as 09:xx AM in WINDOWS taskbar.
Pls, give me solution for this problem. Thank You very much.
Satrio.I ASSUME your variable %time% looks like this: hh:mm:ss
set time=%time::=_% set time=%time: =%
This should substitute : through _ and set it to %time% Then space will be substituted through no space and set it to %time%
The result %time% should be like this: 9_00_00 10_00_00
hope this helps uliWow, that's great ! It's work fine.
C:\>echo %time% 4:44:19.39
C:\>set time=%time::=_%
C:\>set time=%time: =%
C:\>echo %Date:~-4,4%_%Date:~-10,2%_%Date:~-7,2%_%Time%.* 2005_12_29_4_44_35.85.*
I'll wait Your next ideas to make it two digits to CHANGE space char.
Thank You uli_glueck, this solution is good enough !!
|