Computing.Net > Forums > Disk Operating System > Batch files date and time

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Click here to start participating now! Also, check out the New User Guide.

Batch files date and time

Reply to Message Icon

Name: Jaap
Date: May 3, 2002 at 03:59:32 Pacific
Comment:

Hi,

How can i let a batch file change the name of the file, in a name that has the time and date.

thx Jaap.



Sponsored Link
Ads by Google

Response Number 1
Name: Secret_Doom
Date: May 3, 2002 at 11:58:29 Pacific
Reply:

You should get the current date and time into variables, without separators such as "/" (that's not a valid character for filename) and then rename the file using those variables.

The following URL contains a script which will parse current date & time into various variables (date, month, year, hour, etc):
http://www.batch.hpg.com.br/index.htm#05

After getting the variables, you would do (for instance):

REN FILENAME.EXT %DATE%%MONTH%YEAR%--%HRS%%MIN%.DAT

Or however you want the filename format to be. The script from the URL is for Win9x.

-- Secret_Doom - Leonardo Pignataro --

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


0

Response Number 2
Name: vimily
Date: May 28, 2002 at 20:17:58 Pacific
Reply:

how to search for files by date ?

for example before 25/05/02

pls help...thnxx


0

Response Number 3
Name: dennis
Date: June 20, 2002 at 23:13:33 Pacific
Reply:

In your batch for parsing the current date and time into multiple variables, I tried to add a command for renaming a file by your suggested command REN FILENAME.EXT %DATE%%MONTH%YEAR%--%HRS%%MIN%.DAT. After I saved the batch file and run it in the Win 2000 command prompt, an error message 'The syntax of the command is incorrect' appears.

What should I add before the rename command? Please advise!


0
Reply to Message Icon

Related Posts

See More


ERRORLEVEL and environmen... Launching an exe at a spe...



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: Batch files date and time

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

Getting the date and time in a variable www.computing.net/answers/dos/getting-the-date-and-time-in-a-variable/10138.html

DOS - LogFile with Date and Time www.computing.net/answers/dos/dos-logfile-with-date-and-time/3818.html