Computing.Net > Forums > Disk Operating System > Naming files to the current date in Dos

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.

Naming files to the current date in Dos

Reply to Message Icon

Name: Mani
Date: April 10, 2002 at 06:31:13 Pacific
Comment:

Hi

I have setup up a batch job to collect some information. I need to include a command in the batch file so that the name of the file created is the current date. Hve tride using DATE command but has problems with spaces. Can anyone help?



Sponsored Link
Ads by Google

Response Number 1
Name: Cathy
Date: April 10, 2002 at 15:50:54 Pacific
Reply:

Goto the dos directory and type HELP and look for the program you want.


0

Response Number 2
Name: Secret_Doom
Date: April 10, 2002 at 15:54:00 Pacific
Reply:

That's a classic FAQ about batch scripts, discribed on my FAQ:

http://www.secretdoom.hpg.com.br/us/faq.html#getdate2.bat

Go on "Get date into a variable without separators"

All my FAQs are for Win9x.
If you're on NT, try the %date% variable

-- Secret_Doom - Leonardo Pignataro --

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


0

Response Number 3
Name: Jennifer
Date: April 11, 2002 at 05:45:47 Pacific
Reply:

Right. You can't use spaces in DOS. Make the format in this way:

04-11-02

That keeps you within the 8.x naming convention.


0

Response Number 4
Name: Secret_Doom
Date: April 15, 2002 at 21:51:27 Pacific
Reply:

Mani and I changed a couple of emails, and the solutions to get current date into a variable for further use was:

set date2=%date:~4,2%%date:~7,2%%date:~10,4%

Mani is using Windows 2000. This solution will *NOT* work on DOS, only on NT systems (so it won't work on Win9x).

-- Secret_Doom - Leonardo Pigntaro --

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: Naming files to the current date in Dos

creating file names with the date in DOS www.computing.net/answers/dos/creating-file-names-with-the-date-in-dos/9081.html

Rename file to the current date www.computing.net/answers/dos/rename-file-to-the-current-date/13531.html

Rename file to include date www.computing.net/answers/dos/rename-file-to-include-date/13768.html