Append sysdate to file name

  • Thread starter Thread starter Otto Naesset
  • Start date Start date
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
 
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
 
Back
Top