xRobocopy icon indicating copy to clipboard operation
xRobocopy copied to clipboard

Not splatting properly for ExcludeDirs and ExcludeFiles on Dev branch

Open gerane opened this issue 9 years ago • 3 comments

These two params are not working properly. If excluding multiple Files or Directories it thinks they are a single file.

if ($ExcludeFiles) 
    {
        $arguments += @('/XF', $ExcludeFiles)
    }
    if ($ExcludeDirs) 
    {
        $arguments += @('/XD', $ExcludeDirs)
    }

Exclude Directories is actually missing from the parameters as well, so it is being checked for, but not actually available.

Currently, when robocopy runs, the output looks like this

Exclude Dirs

Files : *.*

Exc Dirs : Files Private

Options : *.* /S /E /DCOPY:DA /COPY:DAT /PURGE /MIR /R:1000000 /W:30 

Exclude Files

Files : *.*

Exc Files : Invoke-test.ps1xml Test-*

Options : *.* /S /E /DCOPY:DA /COPY:DAT /PURGE /MIR /R:1000000 /W:30

The files should be on separate lines line the following output.

Exclude Dirs

Files : *.*

Exc Dirs : Files
           Private

Options : *.* /S /E /DCOPY:DA /COPY:DAT /PURGE /MIR /R:1000000 /W:30

Exclude Files

Files : *.*

Exc Files : Invoke-test.format.ps1xml
            Test-*

Options : *.* /S /E /DCOPY:DA /COPY:DAT /PURGE /MIR /R:1000000 /W:30

One way you could handle this is to take ExcludeFolders and ExcludeFiles as arrays, and then add them to the arguments like this.

    if ($ExcludeFiles) 
    {
        $arguments += '/XF'
        $arguments += $ExcludeFiles
    }
    if ($ExcludeDirs) 
    {
        $arguments += '/XD'
        $arguments += $ExcludeDirs
    }

Then even if the files or folders have spaces in their names it works without issue.

An Example when passing arrays:

Files : *.*

Exc Files : Invoke-test.format.ps1xml
             Test-*

Exc Dirs : Files
            Private with spaces

Options : *.* /S /E /DCOPY:DA /COPY:DAT /PURGE /MIR /R:1000000 /W:30

gerane avatar May 12 '16 16:05 gerane

@gerane: thank you for reporting this issue

narrieta avatar May 13 '16 18:05 narrieta

Actual bug; closed by mistake so reopening

narrieta avatar May 13 '16 18:05 narrieta

Hi,

You can use AditionalArgs array to workaround this. I have added some samples in #23;

Arturas-K avatar Jun 13 '16 21:06 Arturas-K