1.

Solve : Batch command to rename file with date help?

Answer»

Was on this site and found code to RENAME a file USING batch but I can not GET it to work

I have a file master.bak in folder T:\backup\master

I WOULD like to rename it with a current date

rename master.bak master03232009.bak

Here is my batch file

echo off
T:
cd\backup\master
for /f "tokens=1-5 delims=/ " %%d in (%date%) do rename "master.bak" master%%e=%%f-%%g.bak

exit

the message I get is

The system cannot find the file mon.

Any idea on what is wrong?


Thanks

Tom try changing:
Code: [Select]for /f "tokens=1-5 delims=/ " %%d in (%date%) do rename "master.bak" master%%e=%%f-%%g.bak

to

Code: [Select]for /f "tokens=1-5 delims=/ " %%d in ('date /t') do rename "master.bak" master%%e=%%f-%%g.bak
thank you for your responce it worked like a champ

thanks again

tom



Discussion

No Comment Found