+ Post New Thread
Results 1 to 6 of 6
Windows Server 2008 R2 Thread, Robocopy script in Technical; Hi guys, This is bit of a difficult one to explain. I want to merge two folders including directory structure ...
  1. #1
    Ben_Stanton's Avatar
    Join Date
    Jan 2007
    Location
    Hertfordshire
    Posts
    420
    Thank Post
    9
    Thanked 14 Times in 13 Posts
    Rep Power
    17

    Robocopy script

    Hi guys,

    This is bit of a difficult one to explain.

    I want to merge two folders including directory structure and files (even if empty). Essentially, I have two copies of one folder (both taken at different times). A straight copy is out of the equation for obvious reasons.

    Folder1 has 14 root folders (and then child folders and files within those). Folder2 has some of the same folders/files, but also new ones. Basically, folder1 has some stuff in it, folder2 has some too.

    Can this be done with robocopy? I also want to keep the data that i'm merging from (not move or mirror). If this can be done, can somebody send some example script as I'm knee-deep in work at moment (aren't we all). Start of term sure does creep up you...

    Thanks in advance... this has been a real dodo of a couple of days!

  2. #2

    Steve21's Avatar
    Join Date
    Feb 2011
    Location
    Swindon
    Posts
    2,654
    Thank Post
    324
    Thanked 506 Times in 474 Posts
    Rep Power
    177
    I think I get the basics, but say for example folder 1 has DocA in, and folder 2 has DocA in but editted later. Which are you wanting to keep?

    Steve

  3. #3
    Ben_Stanton's Avatar
    Join Date
    Jan 2007
    Location
    Hertfordshire
    Posts
    420
    Thank Post
    9
    Thanked 14 Times in 13 Posts
    Rep Power
    17
    Quote Originally Posted by Steve21 View Post
    I think I get the basics, but say for example folder 1 has DocA in, and folder 2 has DocA in but editted later. Which are you wanting to keep?

    Steve
    Sorry, I should have said. I want to keep the newer one.

  4. #4

    Steve21's Avatar
    Join Date
    Feb 2011
    Location
    Swindon
    Posts
    2,654
    Thank Post
    324
    Thanked 506 Times in 474 Posts
    Rep Power
    177
    Should simply be:

    Code:
    Robocopy C:\SourceDir C:\DestDir /E /XO
    /E : Copy Subfolders, including Empty Subfolders.

    /XO : eXclude Older - if destination file exists and is the same date or newer than the source - donít bother to overwrite it.

    Example:

    Code:
    Directory of C:\SourceDir
    
    28/08/2013  15:03    <DIR>          emptyfolder
    28/08/2013  15:03                 0 test1.txt
    28/08/2013  15:04                 0 test2.txt
    
    
    Directory of C:\DestDir
    
    28/08/2013  15:03    <DIR>          .
    28/08/2013  15:03    <DIR>          ..
    28/08/2013  15:03                 0 test1.txt
    28/08/2013  15:03                 0 test2.txt
    
    C:\DestDir>Robocopy C:\SourceDir C:\DestDir /E /XO
    
    -------------------------------------------------------------------------------
       ROBOCOPY     ::     Robust File Copy for Windows
    
    -------------------------------------------------------------------------------
    
      Started : Wed Aug 28 15:04:33 2013
    
       Source : C:\SourceDir\
         Dest : C:\DestDir\
    
        Files : *.*
    
      Options : *.* /S /E /COPY:DAT /XO /R:1000000 /W:30
    
    ------------------------------------------------------------------------------
    
                               2    C:\SourceDir\
    100%        Newer                      0        test2.txt
              New Dir          0    C:\SourceDir\emptyfolder\
    
    ------------------------------------------------------------------------------
    
                   Total    Copied   Skipped  Mismatch    FAILED    Extras
        Dirs :         2         1         1         0         0         0
       Files :         2         1         1         0         0         0
       Bytes :         0         0         0         0         0         0
       Times :   0:00:00   0:00:00                       0:00:00   0:00:00
    
       Ended : Wed Aug 28 15:04:33 2013
    
    C:\DestDir>
    It'll overwrite test2 as it's newer than the destination. But test1 is older so ignored.
    And empty structures get copied etc.

    That what you mean?

    Steve

  5. #5
    Ben_Stanton's Avatar
    Join Date
    Jan 2007
    Location
    Hertfordshire
    Posts
    420
    Thank Post
    9
    Thanked 14 Times in 13 Posts
    Rep Power
    17
    Thanks Steve

    Ha. Well aren't I the div. That wasn't difficult at all. I probably spent longer writing the first post than it would have taken me to do that.

    Thank you very much. I just tested it on some dummy folders and it seems to have worked.

    Ben

  6. #6

    Steve21's Avatar
    Join Date
    Feb 2011
    Location
    Swindon
    Posts
    2,654
    Thank Post
    324
    Thanked 506 Times in 474 Posts
    Rep Power
    177
    Hehe. Yeah it only gets more fun with all the extra options, but hopefully that should do what you're after!

    Steve

SHARE:
+ Post New Thread

Similar Threads

  1. Robocopy - Server Backup Scripts
    By bodminman in forum How do you do....it?
    Replies: 5
    Last Post: 14th January 2011, 02:41 PM
  2. Robocopy Script
    By harrimann in forum Scripts
    Replies: 6
    Last Post: 5th January 2011, 11:41 AM
  3. Robocopy script to move old backups to archive share
    By fat_techie_virgin in forum Scripts
    Replies: 3
    Last Post: 19th October 2010, 01:48 PM
  4. Backup Script for NT backup and Robocopy
    By ChrisH in forum Scripts
    Replies: 12
    Last Post: 20th October 2005, 01:01 PM
  5. The KiXtart free-format scripting language
    By ninjabeaver in forum Downloads
    Replies: 10
    Last Post: 16th June 2005, 12:11 PM

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •