Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.
create file with current datetime
Name: Yin Date: April 22, 2003 at 03:11:57 Pacific OS: DOS CPU/Ram: PIII 800/256
Comment:
I want to create a file with current date and time as the filename, e.g. YYYYMMDD_HHMMSS.txt (HH in 24hrs format). How can I achieve it????
Name: Nick Date: April 22, 2003 at 06:12:54 Pacific
Reply:
type time>time.txt at the dos prompt.
This will creat time.txt with the current time in it.
0
Response Number 2
Name: clug Date: April 22, 2003 at 06:58:55 Pacific
Reply:
Dos only handles 8.3 filenames
0
Response Number 3
Name: Secret_Doom Date: April 22, 2003 at 16:24:16 Pacific
Reply:
Yin wants the date and time stamp on the filename, Nick, not inside the file. And about clug's question, since Yin mentioned a long filename, he's probably on a NT system, just reporting his OS as DOS because he's using the command prompt (which I consider wrong).
After getting the date and time stamps on variables, on the desired format, just use them. Let's say you've sent the time to the %TIME% variable and the date to the %DATE% variable, in the formats desired. Then, you would do something like:
Summary: I want to create a file with Date and time in one line thru single command. currently I can do only date by "date /T > file.txt". But I want both date and time and in the same line. ...
Summary: How do I rename a file with the current date? eg test.txt to text20030422.txt -------------- for /F %%A in ("%DATE%") do ren test.txt test%%C%%A%%B.txt I used the command to renmae my text file, but t...