none
Powershell and the robocopy /xd switch RRS feed

  • Question

  • Hello,

    I am trying to assemble a robocopy command in a powershell script. If the list of excluded directories is sent to robocopy as an array, it does not work:

    $reactIgnores = @( $reactjs + "\.git",$reactjs + "\node_modules",  $reactjs + "\build")

    Robocopy /l $reactjs $synReactjs /mir /xd $reactIgnores


    Yields an Exc Dirs line of:

    Exc Dirs : C:\Users\me\Projects\prj\reactjs\.git C:\Users\me\Projects\prj\reactjs\node_modules C:\Users\me\Projects\prj\reactjs\build


    And it doesn't work (descends into the .git directory immediately).

    If I specify the excluded directories on the command line explicitly, it yields a different Exc Dirs line:

    Robocopy /l /mir $reactjs $synReactjs /xd C:\Users\me\Projects\prj\reactjs\.git C:\Users\me\Projects\prj\reactjs\node_modules 

    Exc Dirs : C:\Users\me\Projects\prj\reactjs\.git            C:\Users\me\Projects\prj\\reactjs\node_modules


    And it works fine. What am I missing in the powershell array assembly? Does't work if I assemble the excluded directories as a string either - what is /xd looking for?


    PS: it is impossible to setup code and output blocks correctly in this forum interface - this question is asked more clearly here:

    https://stackoverflow.com/questions/53087761/robocopy-xd-ignores-a-list-of-directories

    • Edited by O'Mortis Wednesday, October 31, 2018 5:31 PM
    Wednesday, October 31, 2018 5:29 PM

Answers

  • what is /xd looking for?

    A space-delimited set of directory names. If a name contains whitespace, enclose it in quotes.


    -- Bill Stewart [Bill_Stewart]



    Wednesday, October 31, 2018 6:15 PM
    Moderator