Solved how would I rename a file with date

August 29, 2012 at 05:55:04
Specs: Windows 7

I have a folder with an info file that gets saved daily. However it has the same name each time its saved so everytime it is overwritten. How would i rename the file through command prompt to include a time?

example: infofile.txt i would like the file to be renamed infofile"date+time".txt

I've searched and tried diffrent soultions the sytanx im using right now is

C:\>REN C:\Users\Public\Desktop\testCSV\infofile.txt %date:~-10,2%%date:~-7,2%%date:

the infofile txt changes to 08292012.txt however I would also like to add the hour and minutes. Any help is appreciated

Thank you,

See More: how would I rename a file with date

Report •

September 23, 2012 at 08:10:37
✔ Best Answer
rename somefile.txt by adding the time and date to create a unique file name

ren somefile.txt somefile_%time:~0,2%%time:~3,2%-%date:~-10,2%%date:~3,2%%date:~-4,4%.txt

As an example, the code above has just renamed somefile.txt to somefile_1317_13022011.txt (1317hrs on 13th February 2011)

Report •
Related Solutions

Ask Question