- Mar
- 46
- 0
Hello
How to set file time (hour & minute) to a variable ?
I have a piece of complicated code in the bat file. Probably that was because there was no easy way in command.com to find time (hour & minute) of a file as Windows tend to show it in current language, etc. The code would rename existing file name from 200122.doc (i.e. named as per current date) to 200122-1736.doc (i.e. current date-hour&minute).
Now the relevant bat file is called from another btm file and very often (but not always) the result of this program seem to produce error "No" ("200122-no.doc") in the relevant language of my system.
--------------
for /f "tokens=2,3 delims=: " %%i in ('for %%f in ^(%dp%\%dmy%.doc^) do @echo %%~tf') do set ftime=%%i%%j
rename %dp%\%dmy%.doc %dmy%-%ftime%.doc
--------------
How to find hour and minute of the file stamp (lets say, creation or last edit)/write it to variable ?
thanks
How to set file time (hour & minute) to a variable ?
I have a piece of complicated code in the bat file. Probably that was because there was no easy way in command.com to find time (hour & minute) of a file as Windows tend to show it in current language, etc. The code would rename existing file name from 200122.doc (i.e. named as per current date) to 200122-1736.doc (i.e. current date-hour&minute).
Now the relevant bat file is called from another btm file and very often (but not always) the result of this program seem to produce error "No" ("200122-no.doc") in the relevant language of my system.
--------------
for /f "tokens=2,3 delims=: " %%i in ('for %%f in ^(%dp%\%dmy%.doc^) do @echo %%~tf') do set ftime=%%i%%j
rename %dp%\%dmy%.doc %dmy%-%ftime%.doc
--------------
How to find hour and minute of the file stamp (lets say, creation or last edit)/write it to variable ?
thanks