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?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

NVITEnd-user supportCommented:
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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
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
NVITEnd-user supportCommented:
...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
Bootstrap 4: Exploring New Features

Learn how to use and navigate the new features included in Bootstrap 4, the most popular HTML, CSS, and JavaScript framework for developing responsive, mobile-first websites.

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
NVITEnd-user supportCommented:
I can take a look. IDK if I can finish today. I'm in the middle of something right now... 8-)
0
NVITEnd-user supportCommented:
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
NVITEnd-user supportCommented:
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
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Windows OS

From novice to tech pro — start learning today.