Question:
I’m new to powershell and wanted to know if there’s a way to remove a character from a file name. The character I’m trying to remove is a dash “-” and sometimes there are 2 or 3 dashes in the file name. Is it possible to have it rename files that have a dash in them?
Answer:
1 2 3 4 |
Get-Item .\some-file-with-hyphens.txt | ForEach-Object { Rename-Item $_ ($_.Name -replace "-", "") } |
This question may be more suitable for SuperUser.