Append sysdate to file name

O

Otto Naesset

I have a job that copies a file from one server to
another. To retain old versions of the file I want to
append the current system date to the file name. I am not
that familuar with the Windows commands. Can someone help
me with this.

Thanks
Otto
 
R

Ray at

for /f "tokens=2,3,4 delims=/ " %%a in ('date /t') do (set
theDate=%%c-%%a-%%b)
copy \\server1\share\file.txt \\server2\share\%theDate%file.txt

That would output this (in my regional settings of MM/DD/YYYY):
copy \\server1\share\file.txt \\server2\share\2003-12-23file.txt

Ray at work
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top