Computing.Net > Forums > Disk Operating System > DOS Batch File Help

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.

DOS Batch File Help

Reply to Message Icon

Name: DomC
Date: August 20, 2004 at 17:04:32 Pacific
OS: WinXP Pro
CPU/Ram: P4 3.0 GHz
Comment:

Is there any way to get the %time% variable to display as 1340 for example, rather than 13:40:24?

Here is basically what I'm trying to do:

The goal is to copy a file, in this case AppEvent.evt, to a directory every 4 hours. Simple enough with a scheduled copy command batch file or script. The catch here is that the target file needs to have a sequential number or time stamp appended to it's name. This way we don't overwrite the file every 4 hours, but have a bunch of files labeled AppEvent01.evt, AppEvent02.evt, etc.

I'd like to do this task without a 3rd party app. If I can just append the time and date to the end of a file in the correct file format, that would be great.

Thanks for your time.



Sponsored Link
Ads by Google

Response Number 1
Name: Mechanix2Go
Date: August 21, 2004 at 04:08:52 Pacific
Reply:

Hi DomC,

With w2k cmd.exe extensions enabled, you can use the 'tokens.'

I haven't got the hang of it yet. But there are many examples here.

Like you, I like to avoid 3rd party utils.

I wrote a bat which we used to back up a POS, which did an 'if exist' and incremented the letter suffix. A little klunky, be works. You are welcome to a copy.

You could use the w2k built in %random% which id 5 digits and unlikely to cause a name collision any time soon.

If it's mission critical, put in an 'if exist' and get a fresh random number.



0
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: DOS Batch File Help

Quick! Know dos? batch files? help! www.computing.net/answers/dos/quick-know-dos-batch-files-help/4231.html

DOS Batch file help www.computing.net/answers/dos/dos-batch-file-help/6382.html

Need help with a Dos batch file www.computing.net/answers/dos/need-help-with-a-dos-batch-file/13006.html