troubleshooting Question

How do I create filename with date/time using BAT script

Avatar of Gary Antonellis
Gary AntonellisFlag for United States of America asked on
Microsoft DOSWindows XP
4 Comments1 Solution570 ViewsLast Modified:
I need to rename a file with the date/time.  The following script is failing when the time is between 1:00 and 9:59 because the time is one digit and the string is shifting left on character.

ren Filename.log Filename%date:~4,2%%date:~7,2%%date:~10,4%%time:~0,2%%time:~3,2%%time:~6,2%.log
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 4 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 4 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros