none
Robocopy Version XP010 - Excluding Multiple Directories using /XD

    Question

  • I'm attempting to use Robocopy to routinely copy data between 2 servers.  In the file structure being copied there are several folders + their associated sub-folders e.g DfsrPrivate and Projects\Archived for this example I don't want to copy.

     

    I've attempted to use the switches  /XD DfsrPrivate /XD Projects\Archived

    /XF is also used to exclude all .bak files. (referenced after the 2 /XD switches)

     

    This results in the log file header below:


    -------------------------------------------------------------------------------
       ROBOCOPY     ::     Robust File Copy for Windows     ::     Version XP010
    -------------------------------------------------------------------------------

      Started : Wed Dec 05 00:51:28 2007

       Source : \\[Servername]\Data\
         Dest : D:\Data\

        Files : *.*
        
    Exc Files : *.bak
        
     Exc Dirs :  DfsrPrivate
         Projects\Archived
         
         
      Options : *.* /S /E /COPYALL /ZB /MAXAGE:1 /R:10 /W:30

    ------------------------------------------------------------------------------

     

    This results in the DfsrPrivate being excluded but Projects\Archived and all the subfolders below are not.

     

    Has any one had experience with trying this, and had success?
    Wednesday, December 05, 2007 7:35 AM

All replies

  • Try: /XD *"DfsrPrivate" *"Projects\Archived"
    Thursday, February 21, 2008 10:24 AM
  • I can confirm that the robcopy /XD switch works great, even with the /Purge switch. This way robocopy will not put lots of Access Denied entries in your robocopy log file for the DFS replication private folder DfsrPrivate and all it's sub folders.

     

    Here's my example robocopy script using the /XD switch:

     

    Set Source=\\okrs0172\ghost$
    Set Destination=\\okrsvh0100\ghost$
    Set LogFile=C:\Logs\Base_Image_OKR.txt

     

     rem copy _Base and Drivers folders for DFS replication which starts with OKRSVH0100

     

    robocopy %Source%\_Images\XP\_Base %Destination%\_Images\XP\_Base /z /e /np

    /XD DfsrPrivate /purge /r:10 /w:30 /log:%LogFile%

     

    Enjoy,

    ZippyD

    Thursday, April 17, 2008 8:05 PM
  • You both missed his point;  he has a two-part path of "Projects\Archived"

     

    Yes, one-part paths (ie. actual dir names) work fine (as the OP stated).  However, when you don't want all instances of "Archived" to be excluded (just the instance in the "Projects" folder), robocopy does not work as advertised.

     

    BTW, jimahs, you should try your recommendations before posting, as *"Projects\Archived" causes robocopy to puke:

     

    ERROR : Invalid Parameter #nn : "*Projects\Archived" (yes, even though I placed the asterisk prior to the opening quote, it shows up to the right of the opening quote in the error message)

     

    Does anyone out there have any *real* solutions?

     

    Saturday, July 05, 2008 6:27 PM
  • I have found that multi-part paths can be excluded if they are fully qualified, for example:

     

    c:\Projects\Archived

     

    Monday, September 08, 2008 7:43 PM
  •  

    I haven't found this - e.g. /XD D:\Testing\Source\DirA\Subdir1 - this switch still results in a DirA\Subdir1 being created and populated with files in my destination.
    Wednesday, September 10, 2008 12:25 AM
  • Using version XP010 of RoboCopy, I was able to copy a root share and exclude multiple folders with one command. The folders I wanted to exclude had common names, so I opted to use full paths. This is my XD switch:

     

    Code Snippet

    /XD G:\RootShare\Level1\SomeFolder "G:\RootShare\Level1\Folder with Spaces" "G:\RootShare\Level4\Some Other Folder"

     

     

    Use the /L switch for testing.....with this /L switch I ran a full test copy of the root share in 60 seconds, for 1TB of data.
    Thursday, October 02, 2008 6:53 PM
  • I agree... the full path relative or mapped, and use ""
    ie /XD "\\server\share\share\" "\\server\share2\share" "\\and so on and so on"
    works great.. if you are not sure use /l to generate a list and review b4 you run
    Monday, December 01, 2008 5:38 PM
  • I have the same problem too on Windows 2003.  I can only exclude the first of 2 long directories with spaces in the path.

     

    • Proposed as answer by biggigunn Friday, January 25, 2013 4:10 PM
    Thursday, June 30, 2011 9:24 PM
  • @JS2010, You should put the directories in quotes.

    robocopy %source% %destination% /COPYALL /S /XD "C:\MyDirs\ExcludeDir1" "c:\MyDirs\ExcludeDir2" "c:\MyDirs\ExcludeDir3"


    Thursday, July 14, 2011 5:23 PM
  • I'm seeing the same behavior as the OP, and the quotes don't work (windows 2008 R2 server)

    My output file looks like this;


    -------------------------------------------------------------------------------
       ROBOCOPY     ::     Robust File Copy for Windows                             
    -------------------------------------------------------------------------------

      Started : Mon Aug 15 15:17:29 2011

       Source : \\tsclient\C\test\
         Dest : C:\test\

        Files : *.*
        
     Exc Dirs : "c:\test\content\uploads\"
         "\\tsclient\c\test\content\uploads"
        
      Options : /JOB *.* /S /E /COPY:DAT /PURGE /MIR /R:1000000 /W:30

    ------------------------------------------------------------------------------

                        1 \\tsclient\C\test\
                        1 \\tsclient\C\test\content\
                        1 \\tsclient\C\test\content\uploads\
       *EXTRA File          0 blah - Copy - Copy.bmp
       *EXTRA File          0 blah - Copy.bmp

    ------------------------------------------------------------------------------

     

    It should entirely ignore the \content\uploads folder (I've excluded both the source and the dest instances of that folder) - instead it consistently whacks my files

     

    Monday, August 15, 2011 7:20 PM
  • I believe the problem lies within the "\" at the end of the source and destination directories.  I was able to successfully run a directory exclusion with something similar to the below:

    C:\Downloads\robocopy.exe "E:\Working\Data" "C:\Users\Data\Documents" /E /R:3 /W:5 /V /ETA /XD "E:\Working\Data\My Pictures" "E:\Working\Data\My Videos" "E:\Working\Data\My Music"

     

    This successfully copied the contents of an XP "My Documents" Folder while excluding the pictures, videos, and music folders.

     

    Wednesday, October 19, 2011 4:57 PM
  • Using the /XD or /XF parameter in a RoboCopy JOB file, utter failure.

    Complained of a bad parameter on line where the /XD resided. 

    Same exact parameters at the command line, worked fine.  Kind sucked that i wasted yet another Saturday to do this the correct, repeatable, and automated way, but something messed up with robocopy jobs killed it. 

    Monday, March 19, 2012 2:44 AM
  • to exclude directorie use this.

    /xd dfsrprivate Archived 

    this should exclude any folders with the name DFSRPrivate, along with any folders names Archived.

    however is there are some Archived folders you want to back up & others you do not, then you will have to put the path to the ones you do not in the /XD switch.

    ex..

    robocopy D:\example \\example\example /XD DFSRPRivate D:\projects\Archived

    you do not need to state more then 1 /XD switch, just use a space between your folders you want to exclude. also anyfolder pats that have spaces in the name (ie D:\Projects\Archived data) you must contain the folder between 2 quotes (ie "D:\Projects\Archived data")

    • Proposed as answer by Steve_Lindsey Friday, September 21, 2012 2:49 PM
    Friday, September 21, 2012 2:49 PM
  • I had the same problem with my robocopy script, an example of what I had before is below:

    robocopy C:\Folders C:\Temp /E /MINAGE:31 /R:1 /W:5 /L /XD "C:\Folders\Subfolder1" "C:\Folders\Subfolder2"

    I have found that my script works by removing the full path from the exclude command as follows:

    robocopy C:\Folders C:\Temp /E /MINAGE:31 /R:1 /W:5 /L /XD "Subfolder1" "Subfolder2"

    This successfully excludes the subfolders mentioned and all subsequent sub folders within them (for example "C:\Folders\Subfolder1\TEST" and "C:\Folders\Subfolder1\TEST2" etc)

    Hope this helps.



    • Edited by MikeW1982 Friday, April 05, 2013 1:30 PM
    • Proposed as answer by T_Bagger Saturday, May 18, 2013 3:08 PM
    • Unproposed as answer by T_Bagger Saturday, May 18, 2013 3:08 PM
    • Proposed as answer by T_Bagger Saturday, May 18, 2013 3:09 PM
    Friday, April 05, 2013 1:29 PM
  • I am using ROBOCOPY XP027 - Comes with W7

    The /XD switch in the command line works fine, not so in the job:

    THIS WORKS FINE:

                 ROBOCOPY /XD DIR1 DIR2 DIR3

    THIS DOES NOT WORK

                 ROBOCOPY /job:TEST1
    .......
    TEST1.RCJ

    /XD
          DIR1
          DIR2
          DIR3

    any clue is welcome


    • Edited by Cap Kirk 01 Sunday, August 18, 2013 5:11 PM
    Sunday, August 18, 2013 5:10 PM
  • I am using ROBOCOPY XP027 - Comes with W7

    The /XD switch in the command line works fine, not so in the job:

    THIS WORKS FINE:

                 ROBOCOPY /XD DIR1 DIR2 DIR3

    THIS DOES NOT WORK

                 ROBOCOPY /job:TEST1
    .......
    TEST1.RCJ

    /XD
          DIR1
          DIR2
          DIR3

    any clue is welcome


    I typically dont call upon job files, as i never need them.

    however, i think that you may need to be a bit more granular with the job, IE, try to list the full path to the file.

    Also what error msg does Robocopy throw at you?

    Tuesday, October 22, 2013 7:54 PM
  • Using quotes around pathnames is essential. If you have a space issue, and if the server supports it, use the short names of the directories. To access, add the "/X" parameter to a "dir" command, as in:

         C:\>dir /x
          Volume in drive C is Operating System
          Volume Serial Number is BEG2-DIFF
        
          Directory of C:\
         ...
         01/10/2014  10:32 AM    <DIR>          PROGRA~1     Program Files
         12/13/2013  03:44 PM    <DIR>          PROGRA~2     Program Files (x86)
         09/26/2013  07:54 AM    <DIR>          R_FUNC~1     R_Functions
         ...    

    Now you know you can refer to "program files" as PROGRA~1 and "program files (X86)" as PROGRA~2 - with or without quotes.

    Friday, January 10, 2014 10:30 PM