Copy files based on "CREATED" date

Posted on 2007-08-03
Last Modified: 2013-11-05
I need to copy files from multiple directories to the same directories on another server based on their CREATED date.  Not the ACCESSED DATE.  

If I created a file (or folder or both) from July 13 2007 through August 5th 2007, I need to copy those Files/Directories to the same directory structure on another server (under different root folder).

D:\Company\Folder 1\File1.txt (Created 7/21)
D:\Company\Foler 23\File23.txt (Created 7/16)
D:\Company\Folder 5\File5.txt (Created 7/29)

Would need to go over to another server:
D:\datacopy\Company\Folder 1\File1.txt
D:\datacopy\Company\Foler 23\File23.txt
D:\datacopy\Company\Folder 5\File5.txt

But if there are other files / folders under the source, I do not want them to go over if their created date is older than 7/13/2007.

Complex I know, I am currently using ROBOCOPY with the MAXAGE: but it is bringing everything that has been accessed/modified/created/etc since that date.
Question by:red_level
    LVL 38

    Expert Comment

    by:Philip Elder

    Download and install Beyond Compare 2. It does that and more. It is capable of being scripted.


    Author Comment

    Since I don't know this product, can you assist as to where in the program my selection of "CREATED DATE" filter would be...I am looking through it currently and have not yet found it.
    LVL 38

    Expert Comment

    by:Philip Elder
    When in the program, click on the filter button. Looks like a pair of glasses. There is a date tab there that enables you to set the date delimiter.


    Author Comment


    That only has the Exclude older files.  Which means that if the file was "modified" after my date, it will include that in the selection.  I don't want that, I only want file that are specifically CREATED on or after a specific date.  Not anything modified or accessed or anything else.  

    We are importing files into sharepoint for this and going through 300GB of company data (less anything created or modified before a specific date) will probably still be a lot of data to purge through.  Unless there is another filter, this is performing the exact same as robocopy, which I already have a script for but it copies everything within that date and time stamp, not just the NEWLY CREATED stuff.
    LVL 9

    Accepted Solution

    I have used the attached batch file in the past, don't recall if it was under 2000, xp or what so I would definately test first.  If you need to take over permissions you will need to change the copy command to xcopy or robocopy etc...

    REM %1 is source
    REM %2 is oldestdate YYYYMMDD
    REM %3 is destination
    REM %4 is newestdate YYYYMMDD
    REM This batch will copy everything from Source to Destination
    REM that was created on or between oldestdate and newestdate
    If "%3"=="" @echo Syntax: CopyCreated Folder Oldest_YYYYMMDD Drive_path Newest_YYYYMMDD:&goto :EOF
    If "%4"=="" @echo Syntax: CopyCreated Folder Oldest_YYYYMMDD Drive_path Newest_YYYYMMDD:&goto :EOF
    If "%2"=="" @echo Syntax: CopyCreated Folder Oldest_YYYYMMDD Drive_path Newest_YYYYMMDD:&goto :EOF
    If "%1"=="" @echo Syntax: CopyCreated Folder Oldest_YYYYMMDD Drive_path Newest_YYYYMMDD:&goto :EOF
    if not exist %1 @echo Syntax: CopyCreated Folder YYYYMMDD Drive: - %1 not found.&goto :EOF
    if not exist %3 @echo Syntax: CopyCreated Folder YYYYMMDD Drive: - %3 not found.&goto :EOF
    set folder=%1
    set oymd=%2
    set drv=%3
    set nymd=%4
    for /f "Tokens=*" %%a in ('dir %folder% /b /a-d /s') do (
     for /f "Tokens=1-3* Delims=/ " %%b in ('dir "%%a" /TC ^|find /I "%%~nxa"') do (
      set /a YYYY=10000%%d%%10000
      if !YYYY! LSS 2000 set /A YYYY=!YYYY! + 2000
      set /a MM=100%%b%%100
      if !MM! LSS 10 set MM=0!MM!
      set /a DD=100%%c%%100
      if !DD! LSS 10 set DD=0!DD!
      set YYYYMMDD=!YYYY!!MM!!DD!
      IF "!YYYYMMDD!" LEQ "%nymd%" if "!YYYYMMDD!" GEQ "%oymd%" @echo "%%a"
      IF "!YYYYMMDD!" LEQ "%nymd%" if "!YYYYMMDD!" GEQ "%oymd%" if not exist "%drv%%%~Pa" MD "%drv%%%~Pa"
      IF "!YYYYMMDD!" LEQ "%nymd%" if "!YYYYMMDD!" GEQ "%oymd%" copy "%%a" "%drv%%%~Pa*.*"
    LVL 38

    Expert Comment

    by:Philip Elder

    Sorry about that. We ended up with a couple of client emergency situations that needed to be taken care of before we ourselves took a break!

    I couldn't get back to this any sooner.

    You are correct. It looks as though the utility will grab whatever was marked by a certain date and newer or older. There is no delimiter for created, accessed, or modified.

    This utility should do the trick:

    It is robust in nature, and should give you the ability to copy by create date.


    LVL 1

    Expert Comment

    Forced accept.

    EE Admin

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Too many email signature updates to deal with?

    Are you constantly visiting users’ desks making changes to email signatures? Feel like it’s taking up all of your time? Wish you could manage all signatures from one central location, easily design them and deploy them quickly to users? Well, there is an easy way!

    Suggested Solutions

    Recently Microsoft released a brand new function called CONCAT. It's supposed to replace its predecessor CONCATENATE. But how does it work? And what's new? In this article, we take a closer look at all of this - we even included an exercise file for…
    This is an article about Leadership and accepting and adapting to new challenges. It focuses mostly on upgrading to Windows 10.
    The viewer will learn how to download, install and use CrashPlan from on Windows 7. Open your browser and go to Click get started, it’s free then Click the Download CrashPlan button: Click save in Internet Explorer, the…
    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…

    759 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

    12 Experts available now in Live!

    Get 1:1 Help Now