Adding date / time to filename from within a bat file

I was trying to create a new filename with the cuireent date and time from a bat file.

The standard command of %date% and %time% weren’t working as a filename as they crated / and : symbols

Non working example

ren myfile.txt mynewfile-%date%-%time.txt

This won’t work because it would create the file

mynewfile-11/01/2018-11:11:29

Working example using

ren myfile.txt %date:/=% and %time::=%

Creates

mynewfile-14072018-144329.21
Print Friendly, PDF & Email

More Like This


Categories


Win 7 / 10 Tips & Tricks Windows XP Tips & Tricks

Tags