SharonBernal
asked on
Copy a file and appending a timestamp to its name...
I need to know if I can append the timestamp to the end of the filename using the command line in Windows XP. I have a couple of jobs in Unix, where I can do this, and I need help doing this in Windows.
Example:
I have a file: CCAOPCL.txt (it always has this name)
I want to copy that file to:
CCAOPCL_20060523.txt
Example:
I have a file: CCAOPCL.txt (it always has this name)
I want to copy that file to:
CCAOPCL_20060523.txt
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
here's my own personal batch,
::: will set zdate to YYYYMMDD
SET zdate=%date:~-4%%date:~4,2 %%date:~7, 2%
::: will add date to end of file name
COPY c:\CCAOPCL.txt c:\CCAOPCL_%zdate%.txt
::: will set zdate to YYYYMMDD
SET zdate=%date:~-4%%date:~4,2
::: will add date to end of file name
COPY c:\CCAOPCL.txt c:\CCAOPCL_%zdate%.txt
Here's an example script which gets the date/time of a file, among others.
http://www.winscripter.com/WSH/FileIO/68.aspx
For copying the file, you can do something like fso.CopyFile(src,dest,true