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

Posted on 2006-05-23
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
    LVL 5

    Expert Comment

    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:

    LVL 59

    Accepted Solution

    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

    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

    Threat Intelligence Starter Resources

    Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

    Join & Write a Comment

    There are 2 things you must have in order to connect to the internet behind a router, The "Gateway IP" of the router, which is usually something like, I've seen routers with default values of:,,, …
    cPanel is a Unix based web hosting control panel that provides a graphical interface and automation tools designed to simplify the process of hosting a web site. cPanel utilizes a 3 tier structure that provides functionality for administrators, rese…
    Hi everyone! This is Experts Exchange customer support.  This quick video will show you how to change your primary email address.  If you have any questions, then please Write a Comment below!
    Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

    734 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

    Need Help in Real-Time?

    Connect with top rated Experts

    19 Experts available now in Live!

    Get 1:1 Help Now