Removing the enDash [char]0x2013 from filenames

Hi all,

I am struggling trying to remove a specific character from filenames. enDash, or [char]0x2013.

Can someone help me with this ?

Get-ChildItem -path $FileDir -Filter [char]0x2013 -Recurse | Rename-Item -NewName {$_.name -replace [char]0x2013, "_"}

Isn’t it working ? It works for me in PS 5.1 and later.

Wouldn’t you need wildcards?

Get-ChildItem -Filter *$([char]0x2013)* | Rename-Item -NewName {$_.name -replace [char]0x2013, "_"} -whatif

Thanks for the help!

Got it working now :slight_smile:

Get-ChildItem -path $FileDir -Filter “$([char]0x2013)” -Recurse | Rename-Item -NewName {$.name -replace [char]0x2013, ""}