sbergwall / RobocopyPS

RobocopyPS
MIT License
51 stars 9 forks source link

Correct order of precedence #8

Closed MAXxATTAXx closed 3 years ago

MAXxATTAXx commented 3 years ago

Split will get executed after the append action. The intended action is to split the string of arguments and then append to the current list. This is a bug for for sources and destinations that have multiple spaces together.

The new script:

$source = "`"C:\test\path  with  multiple  spaces\src`""
$destination = "`"C:\test\path  with  multiple  spaces\dst`""
$RobocopyArguments = $source , $destination 
$RobocopyArguments + ("/bytes /TEE /np /njh /fp /ndl /ts /quit" -split " ")

Generates this output:

"C:\test\path  with  multiple  spaces\src"
"C:\test\path  with  multiple  spaces\dst"
/bytes
/TEE
/np
/njh
/fp
/ndl
/ts
/quit

The old script:

$source = "`"C:\test\path  with  multiple  spaces\src`""
$destination = "`"C:\test\path  with  multiple  spaces\dst`""
$RobocopyArguments = $source, $destination
$RobocopyArguments + "/bytes /TEE /np /njh /fp /ndl /ts /quit" -split " "

Generates this output:

"C:\test\path

with

multiple

spaces\src"
"C:\test\path

with

multiple

spaces\dst"
/bytes
/TEE
/np
/njh
/fp
/ndl
/ts
/quit