Suppose
Dir /a-D /b >%date%%time%.txt
How to refer to that file further down the code?
Time would have advanced so %date%%time%.txt won't be found.
Refer to file made by date / time variable
Moderator: DosItHelp
Re: Refer to file made by date / time variable
You know, there is a "Search this forum..." field directly on top of the list view of threads ...
Obviously you're asking questions before you even tried out anything. Not only that %time% advances, it also contains colons which are not allowed in file names. Use WMIC. The FOR /F loop in this thread creates a %LocalDateTime% variable that you can cut off after 14 characters in order to contain yyyyMMddHHmmSS. This order has also the adwantage of getting properly sorted in an explorer list view. And obviously a defined variable containing the date-time string can be re-used subsequently in the code, because its value doesn't change anymore.
Steffen
Obviously you're asking questions before you even tried out anything. Not only that %time% advances, it also contains colons which are not allowed in file names. Use WMIC. The FOR /F loop in this thread creates a %LocalDateTime% variable that you can cut off after 14 characters in order to contain yyyyMMddHHmmSS. This order has also the adwantage of getting properly sorted in an explorer list view. And obviously a defined variable containing the date-time string can be re-used subsequently in the code, because its value doesn't change anymore.
Steffen
Refer to file made by date / time variable
Thank you Steffen.
I would have never found it...
Regarding the colons you mentioned, that is why I wrote "suppose'.
I would have never found it...
Regarding the colons you mentioned, that is why I wrote "suppose'.
Refer to file made by date / time variable
Please tell me because all I get is this:
https://www.mediafire.com/view/rn4h4iordpcaqpd
https://www.mediafire.com/view/rn4h4iordpcaqpd
Re: Refer to file made by date / time variable
E.g. if you want to get a timestamp as name for your file:
And once you know that WMIC is worth doing further investigation, just do it.
Steffen
(yellow emphasizing is mine)And once you know that WMIC is worth doing further investigation, just do it.
Steffen
Re: Refer to file made by date / time variable
Thanks again. I will try again when I get to pc