move-item doesn’t work in loop

Question:


So while trying to help someone rename files with [], I found out move-item doesn’t work in a loop. It seems to work just fine outside the loop.

Ideas?

Answer:

Update: Based on the comment below, I want to clarify this: The special characters in the file names require you to use -LiteralPath parameter. -Path cannot handle those characters. Outside a loop, -Path works since you are escapting the special characters using `. This isn’t possible when walking through a collection.

In a loop, you need to use -LiteralPath parameter instead of -Path.

SO, this will be:

Source:

move-item doesn’t work in loop by licensed under CC BY-SA | With most appropriate answer!

Leave a Reply