Computing.Net > Forums > Programming > Batch file help needed

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.

Batch file help needed

Reply to Message Icon

Name: atcusick
Date: February 24, 2005 at 09:43:12 Pacific
OS: XP
CPU/Ram: P4 3 gb
Comment:

I am attempting to create a log file that appends the system date to the file name in order to avoid renaming the file each time the batch is run. This is being attempted in the shortcut's command line.

For example

$$$$.BAT > C:\test.log 2>&1

How would I append the system date without doing it manually? I attempted syntax such as $$$$.BAT > "C:\test"%DATE% to be left with results of: test Thu

The date output is terminated after the blank space in what should be"Thu 02/24/2005"

Any help would be appreciated, I am avoiding writing a VB program if possible. Changing the date format without modifying config would be nice too. Thanks!



Sponsored Link
Ads by Google

Response Number 1
Name: atcusick
Date: February 24, 2005 at 11:34:31 Pacific
Reply:

discovered that the following code works:

$$$$.BAT > C:\test_%date:~4,2%_%date:~7,2%_%date:~10,4%.log 2>&1

creates test_02_24_2004.log with all error messages written to file. Problem solved. Thanks for taking time to look.


0

Response Number 2
Name: Michael J (by mjdamato)
Date: February 24, 2005 at 12:56:32 Pacific
Reply:

When creating log files the preferred method is to use YYYY MM DD so that the files will be sorted chronologically. Just a suggestion - do what works for you.

Michael J


0

Response Number 3
Name: Mechanix2Go
Date: February 24, 2005 at 23:42:19 Pacific
Reply:

Michael,

Good point.

I never have worked out why Americans persist in the use of DD in the middle.

Or AM/PM time notation.

M2


0

Response Number 4
Name: Guy
Date: February 25, 2005 at 07:52:00 Pacific
Reply:

One caution: the default format of %DATE% and %TIME% will be different in Win2K and XP.

Default formats are controlled in the registry.

Guy


0

Response Number 5
Name: Mechanix2Go
Date: February 25, 2005 at 08:06:23 Pacific
Reply:

Hi Guy,

They're also set in control panel.

M2


0

Related Posts

See More



Sponsored Link
Ads by Google
Reply to Message Icon






Post Locked

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


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: Batch file help needed

Batch file help needed www.computing.net/answers/programming/batch-file-help-needed/13589.html

DOS Batch File Help? www.computing.net/answers/programming/dos-batch-file-help/15613.html

Batch File Help, 'delete all folder www.computing.net/answers/programming/batch-file-help-delete-all-folder/13383.html