none
Robocopy Version XP010 - Excluding Multiple Directories using /XD

    질문

  • 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?
    • 이동됨 Mike CrowleyMVP 2011년 7월 27일 수요일 오전 3:42 (From:Admin)
    2007년 12월 5일 수요일 오전 7:35

모든 응답

  • Try: /XD *"DfsrPrivate" *"Projects\Archived"
    • 답변으로 제안됨 WouterSpeybrouck 2014년 7월 10일 목요일 오전 7:35
    • 답변으로 제안 취소됨 WouterSpeybrouck 2014년 7월 10일 목요일 오전 7:35
    2008년 2월 21일 목요일 오전 10:24
  • 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

    2008년 4월 17일 목요일 오후 8:05
  • 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?

     

    2008년 7월 5일 토요일 오후 6:27
  • I have found that multi-part paths can be excluded if they are fully qualified, for example:

     

    c:\Projects\Archived

     

    2008년 9월 8일 월요일 오후 7:43
  •  

    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.
    2008년 9월 10일 수요일 오전 12:25
  • 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.
    2008년 10월 2일 목요일 오후 6:53
  • 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
    2008년 12월 1일 월요일 오후 5:38
  • I have the same problem too on Windows 2003.  I can only exclude the first of 2 long directories with spaces in the path.

     

    • 답변으로 제안됨 biggigunn 2013년 1월 25일 금요일 오후 4:10
    2011년 6월 30일 목요일 오후 9:24
  • @JS2010, You should put the directories in quotes.

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


    2011년 7월 14일 목요일 오후 5:23
  • 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

     

    2011년 8월 15일 월요일 오후 7:20
  • 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.

     

    2011년 10월 19일 수요일 오후 4:57
  • 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. 

    2012년 3월 19일 월요일 오전 2:44
  • 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")

    • 답변으로 제안됨 Steve_Lindsey 2012년 9월 21일 금요일 오후 2:49
    2012년 9월 21일 금요일 오후 2:49
  • 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.



    • 편집됨 RainhamWolf 2013년 4월 5일 금요일 오후 1:30
    • 답변으로 제안됨 T_Bagger 2013년 5월 18일 토요일 오후 3:08
    • 답변으로 제안 취소됨 T_Bagger 2013년 5월 18일 토요일 오후 3:08
    • 답변으로 제안됨 T_Bagger 2013년 5월 18일 토요일 오후 3:09
    2013년 4월 5일 금요일 오후 1:29
  • 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


    • 편집됨 Cap Kirk 01 2013년 8월 18일 일요일 오후 5:11
    2013년 8월 18일 일요일 오후 5:10
  • 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?

    2013년 10월 22일 화요일 오후 7:54
  • 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.

    2014년 1월 10일 금요일 오후 10:30
  • 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


    This works fine, DO NOT put any quotes eg:

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

     /XD  
        c:\users\user1\AppData\Local\Microsoft\Windows\Temporary Internet Files
        c:\Users\user1\AppData\Local\Temp
        c:\$Recycle.Bin
        c:\MSOCache
        c:\Nvidia
        c:\Perflogs
        c:\Program Files
        c:\ProgramData
        c:\Recovery
        c:\System Volume Information
        C:\SysInternals
        C:\VirtDub
        C:\Windows
        C:\Users\Administrator
        C:\Users\Classic .NET AppPool
        C:\Users\DefaultAppPool
        C:\Users\DefaultAppPool.IIS APPPOOL
        C:\Users\Public
        C:\Users\UpdatusUser
        :: eXclude Directories matching given names/paths.

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

    note the spaces in the Bold lines, all these folders were excluded with Robocopy which is on Windows 7 file version 5.1.10.1027.

    When I tried it with Quotes, everything was being copied.


    • 편집됨 ShandyT 2014년 5월 31일 토요일 오전 11:40
    2014년 5월 31일 토요일 오전 11:39
  • 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



    Robocopy requires a new parameter for each excluded directory in the cli, so perhaps the job file requires the same?

    /XD
          DIR1

    /XD
          DIR2

    /XD
          DIR3

    I am not familiar with using RCJ files, but this is the correct syntax from the cli:

    /XD DIR1 /XD DIR2 /XD DIR3


    Anything in a robocopy command with a /PARAMETER behind it is assumed to be a named file that is to be copied, so when it encounters this it's saying "exclude DIR1 but copy DIR2 and DIR3":

    /XD DIR1  DIR2  DIR3

     

    Also network paths with spaces require a syntax which makes absolutely no sense:

    /"\tsclient\C\users\/"

    • 편집됨 Justin Goldberg 2014년 11월 17일 월요일 오후 8:53 network path
    2014년 11월 17일 월요일 오후 8:51
  • Justin,

    "it's saying "exclude DIR1 but copy DIR2 and DIR3":

    /XD DIR1  DIR2  DIR3"

    If you forgive me, that is incorrect.  However, if I am misunderstanding you, please forgive me.

    I was having a devil of a time copying my files.  I wanted to copy docs.  In looking at the logs, I forgot that the shortcut to my music, pictures, and videos were in there, so it was erring on them.

    "2015/09/12 22:53:43 ERROR 5 (0x00000005) Scanning Source Directory C:\Users\Me\Documents\My Music\
    Access is denied."

    I edited my script exactly that way, though I used quotes for everything (even tho you don't have to if there's no spaces, etc.) and I only wrote /XD once, and the 3 directories like so:

    robocopy "C:\Users\Me\Documents" "D:\CBackup\Documents" /V /S /E /IS /r:3 /w:120 /XD "C:\Users\Me\Documents\My Music" "C:\Users\Me\Documents\My Pictures" "C:\Users\Me\Documents\My Videos" /LOG+:D:\robocopy.txt

    As you can see, I only have "/XD" once, and it knew to exclude all 3 of those directories, not exclude 1 and copy the other 2 like you suggested.

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

      Started : Sat Sep 12 22:56:03 2015

       Source : C:\Users\Me\Documents\
         Dest : D:\CBackup\Documents\

        Files : *.*
        
     Exc Dirs : C:\Users\Me\Documents\My Music
         C:\Users\Me\Documents\My Pictures
         C:\Users\Me\Documents\My Videos
        
      Options : *.* /V /S /E /COPY:DAT /IS /R:3 /W:120

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

    This time, the command ran without hanging up on those 3 directories.

    However, it WILL error if you don't use relative path's.  Allegedly, the documentation says ROBOCOPY only needs the directory if it exists in the source, so I should just need to do "My Music" "My Pictures"...  However, that didn't work for me.  I did indeed need to use the full paths.

    HTH somewhat.

    2015년 9월 13일 일요일 오전 3:28
  • That is so weird.  I had the exact OPPOSITE effect.

    When I was copying from "C:\users\me\documents" and had /XD "My Music", it erred big time.  Kept telling me access denied, and did not list it in the excluded directories section of the summary.

    When I did /XD "C:\users\me\documents\My Music" THEN it excluded "My Music" just fine.

    I may have a diff version of RC, or haven't patched my windows or...Im a yo-yo :)

    Anyway, I got mine working that way.

    2015년 9월 13일 일요일 오전 3:35
  • That is so weird.  I had the exact OPPOSITE effect.

    When I was copying from "C:\users\me\documents" and had /XD "My Music", it erred big time.  Kept telling me access denied, and did not list it in the excluded directories section of the summary.

    When I did /XD "C:\users\me\documents\My Music" THEN it excluded "My Music" just fine.

    I may have a diff version of RC, or haven't patched my windows or...Im a yo-yo :)

    Anyway, I got mine working that way.

    I have the same issue with the /XD

    If I do not specify /XD for each directory to exclude, It does not work as expected. (always with Microsoft)

    server 12R2

    Thanks

    2016년 7월 25일 월요일 오후 1:52
  • Just worth noting that when using quotes, don't include a final "\" on the folder (doesn't seem to matter without quotes, but negates the exclusion with quotes).
    2017년 6월 13일 화요일 오후 12:31
  • Yes: Robocopy DOES NOT LIKE terminal backslashes.

    robocopy C:\Source C:\Destination   :: Good!
    robocopy C:\Source\ C:\Destination\ :: Bad!

    The same is generally true for switch paths, like /XD.
    2017년 7월 5일 수요일 오후 3:36
  • This may be a possible answer.

    I have found that paths should always be in quotes, due to the possibility of spaces (I use a lot of environmental variable substitution where spaces in the pathname is always a possibility).

    However, this causes a problem with the terminal portion of the path.

    If the terminal portion ends without a backslash, robocopy could infer that we want to access a file and not a folder.  On the other hand, ending in a backslash followed by a double quote causes robocopy to ignore the last backslash.

    So I found that you need to add a space following the backslash, THEN place the last double quote, eg:

    "%HOMEDRIVE%%HOMEPATH%\DOCUMENTS%MY_DATA_PATH_WITH_SPACES%\%MYFOLDER%\ "

    (note the assumption here that all environmental variable paths begin with a backslash and end with none.)

    This quoted path format has ALWAYS worked for me with regards to writing a robocopy command line when specifying source and destination folders.  I then list the files names/extensions wildcard as a separate quoted item on the line.

    Possibly this quoted path format may also be usefulwhen specifying quoted included or excluded directories and files.



    • 편집됨 Steve_CTGOV 2018년 7월 12일 목요일 오후 2:33 clarity
    2018년 7월 12일 목요일 오후 2:12