Howdy,cgjoker said:Hi there. Me again.
Thought id put out a new thread to see if anyone can help me.
Id like to rename a file in DOS to include 'date /T' in the filename.
Thanks for this guys - this was just what I was looking for too.cgjoker said:i actually figured it out though. well, with some help. here is the syntax i ended up with..
ren tmp.txt tmp%date:~4,2%%date:~7,2%%date:~10,4%
workingman said:I got the idea from this site as to how to append date/time. I noticed that when(time of day) you execute the ren dos command makes a difference. See bat file below.
IF Not EXIST n:\dbfs\doekasp.txt GOTO DoNothing
copy n:\dbfs\doekasp.txt n:\history\doekasp.txt
Rem rename command is done twice (2) to allow for 1 or 2 digit hour,
Rem If before 10am (1digit) hour Rename starting at location (0) for (2) chars,
Rem will error out, as location (0) will have a space
Rem and space is invalid character for file name,
Rem so second remame will be used.
Rem if equal 10am or later (2 digit hour) then first remame will work and second will not
Rem as doekasp.txt will not be found (remamed)
ren n:\history\doekasp.txt doekasp-%date:~4,2%-%date:~7,2%-%date:~10,4%[email protected]_%time:~0,2%h%time:~3,2%m%time:~6,2%s%.txt
ren n:\history\doekasp.txt doekasp-%date:~4,2%-%date:~7,2%-%date:~10,4%[email protected]_%time:~1,1%h%time:~3,2%m%time:~6,2%s%.txt
Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.
If you're not already familiar with forums, watch our Welcome Guide to get started.
Join over 807,865 other people just like you!