I am writing a script that copies files to another directory. I wanted to append the date to the end of the file but when I try to use %date% I get the following:
copy c:\mydir\file.zip "c:\temp\file-%date%.zip"
The system cannot find the path specified.
0 file(s) copied.
if I remove the %date% it copies just fine
Thanks
Your
%date%
contains some reserved character(s), e.g./
(forward slash). As%date%
strongly depends on user's locale settings, I'd use next locale-independent solution with date inyyyymmdd
format:Resources (required reading, incomplete):
%%~G
,%~1
etc. special page) Command Line arguments (Parameters)%LocalDateTime:~0,8%"
) Extract part of a variable (substring)