+ Post New Thread
Results 1 to 11 of 11
Scripts Thread, robocopy but only if older in Coding and Web Development; Does anybody have a script that will merge two folders together but only transfer files from the first folder with ...
  1. #1

    glennda's Avatar
    Join Date
    Jun 2009
    Location
    Sussex
    Posts
    7,799
    Thank Post
    272
    Thanked 1,134 Times in 1,030 Posts
    Rep Power
    349

    robocopy but only if older

    Does anybody have a script that will merge two folders together but only transfer files from the first folder with they don't exist or are newer then those in the second?

    Trying to do a bit of a botch restore of data!

  2. #2

    Steve21's Avatar
    Join Date
    Feb 2011
    Location
    Swindon
    Posts
    2,689
    Thank Post
    334
    Thanked 515 Times in 483 Posts
    Rep Power
    179
    Code:
    robocopy Source Dest /S /XO
    Is include subfolders, and exclude older.

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

  3. Thanks to Steve21 from:

    glennda (17th December 2012)

  4. #3

    glennda's Avatar
    Join Date
    Jun 2009
    Location
    Sussex
    Posts
    7,799
    Thank Post
    272
    Thanked 1,134 Times in 1,030 Posts
    Rep Power
    349
    I've tried that but for some reason this server tries to add /e /xo as \e \xo on the path?

    Any ideas?
    robocopy error.png

  5. #4

    Steve21's Avatar
    Join Date
    Feb 2011
    Location
    Swindon
    Posts
    2,689
    Thank Post
    334
    Thanked 515 Times in 483 Posts
    Rep Power
    179
    Whats the original command you're running?

    Steve

  6. #5

    glennda's Avatar
    Join Date
    Jun 2009
    Location
    Sussex
    Posts
    7,799
    Thank Post
    272
    Thanked 1,134 Times in 1,030 Posts
    Rep Power
    349
    Code:
    robocopy F:\restore\project\ "F:\projects\Project Directory\" /S /XO
    Just seems to be swapping the /s /xo for \s \xo??

  7. #6

    Steve21's Avatar
    Join Date
    Feb 2011
    Location
    Swindon
    Posts
    2,689
    Thank Post
    334
    Thanked 515 Times in 483 Posts
    Rep Power
    179
    The \ is the problem.

    Code:
    robocopy "F:\restore\project" "F:\projects\Project Directory" /S /XO
    Steve

  8. #7

    Steve21's Avatar
    Join Date
    Feb 2011
    Location
    Swindon
    Posts
    2,689
    Thank Post
    334
    Thanked 515 Times in 483 Posts
    Rep Power
    179
    Adding the \ + Robocopy's own \ makes it escape char ", such that you actually use it in the string

    Steve

  9. #8

    glennda's Avatar
    Join Date
    Jun 2009
    Location
    Sussex
    Posts
    7,799
    Thank Post
    272
    Thanked 1,134 Times in 1,030 Posts
    Rep Power
    349
    Quote Originally Posted by Steve21 View Post
    Adding the \ + Robocopy's own \ makes it escape char ", such that you actually use it in the string

    Steve
    Thanks!! Running now - I had tried removing the \ from the source but not destination.

  10. #9


    Join Date
    Sep 2008
    Posts
    1,752
    Thank Post
    320
    Thanked 258 Times in 211 Posts
    Rep Power
    119
    Not quite the same, but I've copied user home files over to a new server but before we move the users over I want to run robocopy again to pickup any of the files which have been updated or created while we have done this. Can I just add the switch /s /xo to my existing command so I don't copy everything again?

  11. #10

    Steve21's Avatar
    Join Date
    Feb 2011
    Location
    Swindon
    Posts
    2,689
    Thank Post
    334
    Thanked 515 Times in 483 Posts
    Rep Power
    179
    Quote Originally Posted by penfold View Post
    Not quite the same, but I've copied user home files over to a new server but before we move the users over I want to run robocopy again to pickup any of the files which have been updated or created while we have done this. Can I just add the switch /s /xo to my existing command so I don't copy everything again?
    It'll exclude older files (and same etc), but only if in same position etc. If I move ABC.doc into a folder, it's a new file etc, but in terms of what you're saying yes it should do it Make sure it's upper case though, think there's lower case on robocopy too

    Steve

  12. Thanks to Steve21 from:

    penfold (10th January 2013)

  13. #11


    Join Date
    Sep 2008
    Posts
    1,752
    Thank Post
    320
    Thanked 258 Times in 211 Posts
    Rep Power
    119
    I did run a quick test and it seemed to work, but I used lower case so will change that in case it causes problems before running it with live data.

    Thanks

SHARE:
+ Post New Thread

Similar Threads

  1. CS4 Install - only if you disable UAC.
    By Sirbendy in forum Windows 7
    Replies: 0
    Last Post: 14th July 2009, 02:41 PM
  2. FMS Issue (Fix works but only temporarily).
    By Heebeejeebee in forum MIS Systems
    Replies: 11
    Last Post: 19th May 2009, 03:04 PM
  3. Replies: 4
    Last Post: 10th October 2008, 03:40 PM
  4. screen gone strange but only IE7
    By imiddleton25 in forum Windows
    Replies: 0
    Last Post: 24th September 2008, 05:42 PM
  5. Replies: 1
    Last Post: 4th September 2008, 06:31 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
  •