Created
April 15, 2024 18:53
-
-
Save bsharper/e3d5ad6a832622300a724dca565bd5b2 to your computer and use it in GitHub Desktop.
Powershell Show renamer - extracts S00E00 data from filename and renames files for you.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| param ( | |
| [Parameter(Mandatory=$true)] | |
| [string]$ShowName | |
| ) | |
| $files = Get-ChildItem -File -Filter "*.mkv" | |
| foreach ($file in $files) { | |
| $seasonEpisode = [regex]::Match($file.Name, 'S\d{2}E\d{2}').Value | |
| $extension = $file.Extension | |
| if ($seasonEpisode) { | |
| $newFileName = "{0} - {1}{2}" -f $ShowName, $seasonEpisode, $extension | |
| Rename-Item -Path $file.FullName -NewName $newFileName | |
| Write-Host "Renamed: $($file.Name) -> $newFileName" | |
| } | |
| else { | |
| Write-Host "No season/episode pattern found in: $($file.Name)" | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment