robocopy s:\hugefolder to USB:\smallfolder BUTonly files changed yesterday and today.

We are converting from SBS2003 to Windows Server Essentials 2016.

On WedNesday, I RoboCopied \\SBS2003 to \\WSESERVER (160 Gig of data).  I did NOT take SBS2003 out of service.

On Wednesday and Thursday, the users changed about 200 file or folders on SBS2003.
 (200 filenames were listed using this command):

forfiles /P s:\ /S /D +11/04/2017 /c "cmd /c echo @fdate @ftime @path" > c:\aatmp\allchanged

Open in new window


Is there way to get RoboCopy to put those 200 modified file onto a USB while conserving their parentage  structure ?

For instance  
OldStructure
Root\Bob has many subfolders at multiple levels, but no recently modified files anywhere.
root\Chris also has no changes anywhere
root\Joes has this structure
            .\Ohio  has no changes at any level
            .\NY has 20 folders and 100 files at multiple levels, but there was only file modified was:
              root\Joe\NY\Construction\Mainstreet\plan.pdf  (modified yesterday)

The ideal robocopy would create a single file on the USB:
f:\smallFolder\Joe\NY\Construction\Mainstreet\plan.pdf
LVL 5
rberkeConsultantAsked:
Who is Participating?
 
NVITCommented:
This is tested and does what you want.
- Do a test folder first.
- Adjust the various set values per your needs:

Edit: Adjusted DtOldest and DtNewest values to meet your requirement of 'yesterday and today'

@echo off
setlocal EnableDelayedExpansion

set SrcDir=C:\local\test\EE\src
set TgtDir=C:\local\test\EE\tgt
set DtOldest=20171108
set DtNewest=20171110

robocopy /MINAGE:%DtNewest% /MAXAGE:%DtOldest% /e /r:0 /w:0 /dcopy:t "%SrcDir%" "%TgtDir%"

for /f "tokens=*" %%a in ('dir /ad /b /s "%TgtDir%" ^| sort /r') do rd /q "%%a"

Open in new window

0
 
rberkeConsultantAuthor Commented:
Nearly perfect, except it will creates and delete about 80,000 unnecessary folders which make it run really slowly.

Any suggestions?

rberke
P.S.  When  I specify from 11/08/2017 to 11/09/2017, files changed on 11/8 are copied and files changed on 11/09 are NOT copied.  So I will always add 1 to the most recent date desired.
0
 
NVITCommented:
...except it will creates and delete about 80,000 unnecessary folders ...

Unfortunately, that's how robocopy works. It makes the empty folders. Hence, the need for the following RD line.

You may be able to do it with FORFILES without the following RD line. IDK if that's faster than the robocopy method.
0
Cloud Class® Course: Amazon Web Services - Basic

Are you thinking about creating an Amazon Web Services account for your business? Not sure where to start? In this course you’ll get an overview of the history of AWS and take a tour of their user interface.

 
rberkeConsultantAuthor Commented:
Actually, robocopy had other problems.  For some reason it stalls at pst files.   They stay on the screen from for many minutes while a processed percentage works its way up to 100%.   Maybe it is reviewing each email?  Anyway, it looks like it is a dead end.

back kto the drawing board.
0
 
rberkeConsultantAuthor Commented:
do you think you could come with a forfiles command?  I am not good at that stuff.  If  not, I will give you points for your previous answer and close the question.
0
 
NVITCommented:
I can take a look. IDK if I can finish today. I'm in the middle of something right now... 8-)
0
 
NVITCommented:
As far as the PST issue... I don't think it matters if robocopy or forfiles is used. Both use COPY commands. If those are large pst files, it will surely take awhile to copy.
0
 
NVITCommented:
Also, If the PST file is open, i.e. being used by someone, robocopy or forfiles COPY won't be able to copy the pst file. Because Outlook locks the file. Until the user closes Outlook.
0
 
rberkeConsultantAuthor Commented:
I was wrong, the PST was not a problem. It was just a big file that took 5 minutes to copy.


My full job ran for about 80 minutes . The good news is that this an acceptable period of time, so  I am closing the question and awarding you points.

But, I still believe an ideal solution without the useless folders would run in half the time.

Here are a few statistics in case anybody is interested. All numbers are chancy because I did not keep an accurate log.



To get timing statistic I removed your delete loop and reran the job. It ran much faster and finished in 60 minutes

This created C:\aatmp\arobotest2 with 1037 files in 61,084 folders.



I tnen ran your delete logic on arobtest2.  It ran for about 20 minutes

and changed C:\aatmp\arobotest2 to have 1037 files in 172 folders.

So, 60,818 useless folders were deleted in 20 minutes.


My guess is that creating those useless foders also took an additional 20 minutes.

So, the ideal robocopy should have taken 40 minutes instead of 80 minutes.

So, while your solution is not ideal, it works fine.

Thanks for your help.
0
 
rberkeConsultantAuthor Commented:
thanks again
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.