Learn how to a build a cloud-first strategyRegister Now


Copy a file and appending a timestamp to its name...

Posted on 2006-05-23
Medium Priority
Last Modified: 2007-11-27
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:

Question by:SharonBernal

Expert Comment

ID: 16747269
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: http://www.winscripter.com/WSH/FileIO/290.aspx)

LVL 59

Accepted Solution

LeeTutor earned 1000 total points
ID: 16747350
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.
LVL 14

Expert Comment

ID: 16749422
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


Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If your system is showing symptoms of browser hijacks or 'google search redirects' check out my other article (http://rdsrc.us/u3GP7A) first and run the tool TDSSKiller (http://rdsrc.us/GDBBs4) to get rid of the infection. Once done, and if the …
For both online and offline retail, the cross-channel business is the most recent pattern in the B2C trade space.
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…
As many of you are aware about Scanpst.exe utility which is owned by Microsoft itself to repair inaccessible or damaged PST files, but the question is do you really think Scanpst.exe is capable to repair all sorts of PST related corruption issues?
Suggested Courses
Course of the Month21 days, 2 hours left to enroll

810 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question