[Last Call] Learn how to a build a cloud-first strategyRegister Now

  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 2684
  • Last Modified:

Copy files based on "CREATED" date

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.
1 Solution
Philip ElderTechnical Architect - HA/Compute/StorageCommented:

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

red_levelAuthor Commented:
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.
Philip ElderTechnical Architect - HA/Compute/StorageCommented:
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.

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

red_levelAuthor Commented:

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.
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!
  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*.*"
Philip ElderTechnical Architect - HA/Compute/StorageCommented:

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: http://www.xxcopy.com/

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


Forced accept.

EE Admin

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now