Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
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.

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#05After 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

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!

![]() |
ERRORLEVEL and environmen...
|
Launching an exe at a spe...
|

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