General discussion

Locked

All you DOS gurus: got a tough one!

By CVN70_IT2 ·
Okay, so I am the admin guy for a system that creates a log file after the nightly backups. I want to copy the file (which I know how to do) and name it to the current date. I am using the following commands:

FOR /F "tokens=1-4 delims=/ " %i in ('date /t') do set filerename=%j%k%%l
and
RENAME file.log %filerename%.log
These run fine by themselves, but they don't run in the batch file I created. Does anyone know why? It's killin me! Thanks!

This conversation is currently closed to new comments.

1 total post (Page 1 of 1)  
| Thread display: Collapse - | Expand +

All Comments

Collapse -

Double Percent Signs

by JackOfAllTech In reply to All you DOS gurus: got a ...

To avoid variable substitution in a batch file, you must use double percent signs. Change the first line to

FOR /F "tokens=1-4 delims=/ " %%i in ('date /t') do set filerename=%%j%%k%%l


Ralph

Back to IT Employment Forum
1 total post (Page 1 of 1)  

Related Discussions

Related Forums