How can I force robocopy to copy files from the oldest date to the newest date

Posted on 2007-10-18
Last Modified: 2012-06-21
How can I force robocopy to copy files from the oldest date to the newest date? I have noticed by default it does newest file to oldest file.
Question by:sqlagent007
    LVL 38

    Expert Comment

    Please explain further and give some examples of what you're trying to accomplish.
    LVL 1

    Author Comment

    If I have files named:


    Does Robocopy start with A and move to Z or does it go by datestamp?
    LVL 38

    Accepted Solution

    Going by its logfiles, it appears to go through files alphabetically by default.  I don't know of any native switches to change the order in which files are copied.  

    You could use a FOR loop to cycle through the output of DIR|SORT and copy files one-by-one that way.
    LVL 38

    Expert Comment

    Come to think of it, dir /O would be better.  Something like this:

    @echo off

    set source=c:\folder1
    set dest=d:\folder2

    for /F "usebackq tokens=*" %%G in (`dir "%source%" /A:-D /B /O:D`) do (
     robocopy "%source%" "%dest%" "%%G" /ZB


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    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.

    Many admins will agree: WSUS is is a nice invention but using it on the client side when updating a newly installed computer is still time consuming as you have to do several reboots and furthermore, the procedure of installing updates, rebooting an…
    This is a little timesaver I have been using for setting up Microsoft Small Business Server (SBS) in the simplest possible way. It may not be appropriate for every customer. However, when you get a situation where the person who owns the server is i…
    Windows 8 comes with a dramatically different user interface known as Metro. Notably missing from the new interface is a Start button and Start Menu. Many users do not like it, much preferring the interface of earlier versions — Windows 7, Windows X…
    With the advent of Windows 10, Microsoft is pushing a Get Windows 10 icon into the notification area (system tray) of qualifying computers. There are many reasons for wanting to remove this icon. This two-part Experts Exchange video Micro Tutorial s…

    779 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

    18 Experts available now in Live!

    Get 1:1 Help Now