Date in filename

  • Thread starter Thread starter Faisal
  • Start date Start date
F

Faisal

Dear all,

We wish to copy a file each day with current date as part of file name, like

copy a.log a20031114.log

How can this be achieved?

I will be grateful for any help.


Regards
 
FOR /F "tokens=2-4 delims=/ " %%a in ('date /t') DO SET THEDATE=%%c%%a%%b
copy a.log a%THEDATE%.log

Ray at home
 
(e-mail address removed) (Faisal) wrote in
Dear all,

We wish to copy a file each day with current date as part of file
name, like

copy a.log a20031114.log

How can this be achieved?

I will be grateful for any help.

You could make a batch file (.bat) containing the two lines below, and
schedule it to run once a day, automatically, if that is your wish.

FOR /F "tokens=2,3,4 delims=/ " %%i IN ("%date%") DO Set x=%%k%%i%%j
copy a.log a%x%.log

Cheers,
Joe
 
Back
Top