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.


I have a file:                CCAOPCL.txt (it always has this name)

I want to copy that file to:

Who is Participating?
Here's a web page that describes a batch file to do very close to what you want:

You would need to change the "rename" command to "copy" in the batch file, and if you're not interested in the time being appended to the file name, but only the date, then just leave out references to that.
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.

For copying the file, you can do something like fso.CopyFile(src,dest,true);  (see this other script which performs copying:

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

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.