Archive | January 2015

Move-item and files with [ and ] in its filename

I was researching a bug in a script of mine, where most files would be moved, exept some. The behaviour seemed irregular, until I noticed that the files not being moved had 1 thing in common. They all had brackets [ ] in their file name. It appears that if you use Move-item -Path <filename> -Destination <destination path> it won’t work on files with those brackets in its name. To make Move-item move these files too, use the switch LiteralPath instead of Path:

Move-Item -LiteralPath <filename> -Destination <destination path>