You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Move-Item, Remove-Item don't work with paths containing \, [, ] on unix #3414
The problem happens not only with Compress-Archive, but with other archive programs too. So macOS users need a way to bulk-rename files with \ in the name and PS doesn't provide a way to do it at the moment.
UPD: same problem for paths like [foo].
Expected behavior
PowerShell should be able to perform the operations
Actual behavior
Paths are getting normalized to 1/2
rm : Cannot find path '/Users/vors/dev/PowerShell/1/2' because it does not exist.
changed the title [-]Move-Item, Remove-Item don't work with \-paths on unix[/-][+]Move-Item, Remove-Item don't work with paths containing \, [, ] on unix[/+]on Apr 26, 2017
Regarding the operations on [foo]: [foo] is a shell globbing pattern, so you should probably use -LiteralPath when trying to give that filename to Remove-Item.
It probably still won't work right now, but I have a fix for #2799 coming that seems to also fix that, as well as the Remove-Item -Recurse -Force * issue. I haven't looked at this for the \ character, so I can't yet say whether my changes will fix that part.
The remaining thing for this issue are backslashes (\) that are covered in greater detail in a linked issue #3666 (On Unix, PowerShell will not find files with backslashes in their names), so closing this one.
Activity
lzybkr commentedon Mar 24, 2017
Aren't
mvandrmthe Unix utilities? Assuming so, we shouldn't assume an argument that looks like a path is actually a Unix path.daxian-dbw commentedon Mar 24, 2017
Weird, I cannot reproduce this:
Environment
vors commentedon Mar 24, 2017
Oh yeah, I mean our versions of rm and mv (aliases)
[-]mv, rm don't work with \-paths on unix[/-][+]Move-Item, Remove-Item don't work with \-paths on unix[/+]joeyaiello commentedon Mar 24, 2017
Update the title to reflect the issue more accurately.
[-]Move-Item, Remove-Item don't work with \-paths on unix[/-][+]Move-Item, Remove-Item don't work with paths containing \, [, ] on unix[/+]vors commentedon Apr 26, 2017
The other thing with path like
[foo]is that you cannot useremove-item -recurse -force .to get rid of them.I.e.
jeffbi commentedon Apr 26, 2017
Regarding the operations on
[foo]:[foo]is a shell globbing pattern, so you should probably use-LiteralPathwhen trying to give that filename toRemove-Item.It probably still won't work right now, but I have a fix for #2799 coming that seems to also fix that, as well as the
Remove-Item -Recurse -Force *issue. I haven't looked at this for the\character, so I can't yet say whether my changes will fix that part.vors commentedon Apr 26, 2017
jeffbi oh, awesome to see that you working on it!
give the same result. I tried few things like explicit escaping with backticks and nothing seems to work.
9 remaining items
anmenaga commentedon Aug 28, 2017
Verified on latest release (v6.0.0-beta.6) on Ubuntu14 that
Move-Item,Remove-Itemwork as expected with[,],*when-LiteralPathparameter is used.anmenaga commentedon Aug 28, 2017
The remaining thing for this issue are backslashes (
\) that are covered in greater detail in a linked issue #3666 (On Unix, PowerShell will not find files with backslashes in their names), so closing this one.