I'm creating a backup script in a .bat file in Windows 7. As part of the script I create a log file. I'd like to create the log file with the following date format: YYYYDDMM_HH24MISS_backup.log
Any ideas on how to do this?
|
I'm creating a backup script in a .bat file in Windows 7. As part of the script I create a log file. I'd like to create the log file with the following date format: YYYYDDMM_HH24MISS_backup.log Any ideas on how to do this? | ||||
|
feedback
|
|
substring fun!
then just append data to it in the script:
output filename example: 20092810_23242544_backup.log not sure if you want that 24 hardcoded after the hours in HH 24. | |||||
feedback
|
|
The other answer will choke when the month or hour are less than 10.
You can strip out a lot of it once you are sure it works, and have tested with months and hours less than 10, and your regional settings. Here's the stripped down version without comments, or test cases: Again, check that it works with your regional settings.
| |||
|
feedback
|
|
Thanks for all the help! Using all the information you posted here's what I finally used:
I tried to upvote both your answers but I didn't have enough reputation... | |||
|
feedback
|