Computing.Net > Forums > Disk Operating System > create file with current datetime

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

Reply to Message Icon

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????



Sponsored Link
Ads by Google

Response Number 1
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).

Yin, that is covered in my FAQ:

FAQ #02 - Get system's current date into a variable without separators

FAQ #04 - Get system's current time into a variable without separators

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:

type nul> %DATE%_%TIME%.txt

-- Leonardo Pignataro - Secret_Doom --

secret_doom@hotmail.com
www.batch.hpg.com.br


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Disk Operating System Forum Home


Sponsored links

Ads by Google


Results for: create file with current datetime

Create file with date and time www.computing.net/answers/dos/create-file-with-date-and-time/13843.html

Rename file with current date www.computing.net/answers/dos/rename-file-with-current-date/13069.html

naming files with current date www.computing.net/answers/dos/naming-files-with-current-date/7725.html