Tuesday, September 19, 2023

Using the Windows PowerShell to bulk rename files by stripping a part from the filename

This post demonstrates how to rename files in bulk by stripping off the same part of the filename from each file by using the Windows PowerShell.

For the sake of an example, the below screenshot shows a list of MP3 files from which we want to remove artist names. The part of the filename that we want to remove is marked in red.




This can easily be achieved with the PowerShell by using a command like the one below. Remember to take a backup of the folder just in case you need to restore later. Before executing the command in the PowerShell, change directory to the folder in which the files reside:


get-childitem *.mp3 | foreach { rename-item $_ $_.Name.Replace("Paul Revere & The Raiders - ", "") }


The command executes silently and does a neat job in cleaning up the file names. Here is the result.



No comments:

Post a Comment