The following PowerShell commands are one liners to help you easily organise multiple filenames at once.


Remove the same part of a filename from many files that match a filetype:

If you have multiple files with the same pattern in the filename for example in the picture below Radiohead - . You can run the following line to remove it and replace.

get-childitem *.mp3 foreach { rename-item $_ $_.Name.Replace(“Radiohead -“, “”) }



Add text to the beginning of the filename:

This command will add text to the beginning of the filename for each specified file type.

get-childitem *.avi rename-item -NewName {“Season01$($” }


Clean-Up script which deletes files older than x amount of days:

This script will delete any files that are older then the amount of days you set. This could be run on a task schedule every month to help keep downloaded content low and not taking up disk space for example.

Get-ChildItem –Path “C:\path\to\folder” -Recurse Where-Object {($_.LastWriteTime -lt (Get-Date).AddDays(-30))} Remove-Item


Add S00E Random Number to the front of filtered files

This script will add a random episode number to the beginning of a file name for plex special tv shows.

$originalFiles = Get-ChildItem *.mp4 $x = 1

ForEach ($originalFile in $originalFiles) { Rename-Item -Path $originalFile.FullName -NewName (($originalFile.Directory.FullName) + “\” + “S00E$x - “ + $originalFile.Name) $x++ }