

Otherwise you run the risk of getting the hour:min:sec before midnight and the AMPM after midnight. You should get the entire time string from a single %TIME% expansion. I agree with Joey's comment, I think you are better off with 24 hour format.Īlso, your method for getting the date and time will break as soon as the code is transferred to another machine that uses a different date and/or time configuration. Set /F "tokens=3 delims=: " %%A in ('time /t ') do AMPM=%%AĬopy "C:\Temp\File.xlsx" "C:\Temp\DailyBackup\File %All% %Allm%%AMPM%.xlsx" Would anyone know how to have the time appended in 12 hour clock format rather than 24 hour clock format as it is currently in the code below. File.xlsx is copied and pasted to a new folder as File Sun-06-24-2012 23.21.46PM.xlsxĬurrently the date and time is appended as Sun-06-24-2012 23.21.46PM.xlsx but i would like to have it append as Sun-06-24-2012 11.21.46PM.xlsx using the 12 hour clock rather than 24 hour clock format.īelow is the code i am currently using in Windows XP Professional. it is used to back up an excel spreadsheet file each day and rename it by appending the current date and time.

I currently have the following code in a batch file Backup.bat on my desktop.
