Link to home
Start Free TrialLog in
Avatar of SharonBernal
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

Avatar of Dragon_Krome
Dragon_Krome

I don't think you can do that by using only the commandline. You could try to create a script though, and run it via WSH

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);  (see this other script which performs copying: http://www.winscripter.com/WSH/FileIO/290.aspx)

ASKER CERTIFIED SOLUTION
Avatar of LeeTutor
LeeTutor
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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