powershell Rename-Item fail to rename powershell Rename-Item fail to rename powershell powershell

powershell Rename-Item fail to rename


If you are running PS 3+ add -LiteralPath switch to your rename:

Rename-Item -LiteralPath $folder.FullName $newname

otherwise use Move-Item

Move-Item -LiteralPath $folder.FullName $newname

Powershell doesn't like square brackets in filenames, more in the following post:

This became an issue with V2 when they added the square brackets to the wildcard character set to support "blobbing".

From get-help about_wildcards:

Windows PowerShell supports the following wildcard characters.

Wildcard Description Example Match No match


  • Matches zero or a* A, ag, Apple banana more characters

    ? Matches exactly ?n an, in, on ran one character in the specified position

    [ ] Matches a range [a-l]ook book, cook, look took of characters

    [ ] Matches specified [bc]ook book, cook hook characters

[ and ] are special characters.