Note that there are some explanatory texts on larger screens.

plurals
  1. POCommand Line: Create File Named With Date/Time
    primarykey
    data
    text
    <p>I have seen questions of these sorts listed on the site, and I've tried to work through them but haven't been successful.</p> <p>What I want to do is make .bat file that creates a file (probably just a txt file, but doesn't matter) which has the Date and Time in the name.</p> <p>I can use something like "TYPE File1.txt>"File2 - %DATE% - %TIME%".txt" to make the file (and without the date/time it works fine, and in fact if I change the regional settings to use - or . instead of /and: it works fine, but having the time on the PC with : is really annoying).</p> <p>So I've tried the following which I got from other questions / the internet, and a few other things, but they don't seem to change the format for the date/time</p> <pre><code>M:\&gt;FOR /F "TOKENS=1* DELIMS= " %%A IN ('DATE/T') DO SET CDATE=%%B %%A was unexpected at this time. M:\&gt;FOR /F "TOKENS=1* DELIMS= " %A IN ('DATE/T') DO SET CDATE=%%B M:\&gt;SET CDATE=%20/03/2012 M:\&gt;FOR /F "TOKENS=1,2 eol=/ DELIMS=/ " %A IN ('DATE/T') DO SET mm=%%B M:\&gt;SET mm=%20 M:\&gt;FOR /F "TOKENS=1,2 DELIMS=/ eol=/" %A IN ('echo %CDATE%') DO SET dd=%%B M:\&gt;SET dd=%03 M:\&gt;FOR /F "TOKENS=2,3 DELIMS=/ " %A IN ('echo %CDATE%') DO SET yyyy=%%B M:\&gt;SET yyyy=%2012 M:\&gt;SET date=%mm%%dd%%yyyy% M:\&gt;date/t Tue 20/03/2012 M:\&gt; </code></pre> <p>As you can see, it's not working for me, even when I just call on the date I can see it's wrong...</p> <p>How can I get this working?</p> <p>(To be clear, the end product I want is a shortcut that if clicked at 8:13am on March 20 would makes a file "20120320 0813.txt". Or something very close)</p> <p>(FYI I'm on a corporate PC running XP)</p> <p>Thanks in advance for any help!</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload