Discussion Locked

All you DOS gurus: got a tough one!

0 helpful
1 reply
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

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!

1 reply

by jackofalltech

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

This discussion is closed to new replies.