PowerShell – Remove certain string from multiple filenames


I have multiple .mp3 files in the catalogue and want to remove artist’s name from their filenames.
All the files’ names contain string

“Adhesive Wombat – “

followed by the song’s title.
I want to remove (not replace) every occurence of that specific string in every filename in current folder.

Not to mention, I’ve searched for answer on this site and failed to find an elegant and satisfying solution.

This is my first encounter with PowerShell.


As you know what you have is really close.

You added a stipulation that “Adhesive Wombat” may or may not contain a space. -replace uses regular expressions so lets harness that and make that space optional using a ?. I am also going to show you the full cmdlet name as supposed to aliases so you are aware of what is happening behind the scenes. It’s hard to see but I tried to highlight the ? in bold for it to “pop”.

Get-ChildItem | Rename-Item -NewName {$_.Name -replace "Adhesive ?Wombat - ", "" }

So that will match both

Also, depending on how much white space there is you could use \s+ where you have space which will match all consecutive white space.


PowerShell – Remove certain string from multiple filenames by licensed under CC BY-SA | With most appropriate answer!

Leave a Reply