Skip to content

Instantly share code, notes, and snippets.

@adamwalz
Last active November 10, 2015 20:32
Show Gist options
  • Save adamwalz/18accfde5fdf920831ab to your computer and use it in GitHub Desktop.
Save adamwalz/18accfde5fdf920831ab to your computer and use it in GitHub Desktop.
Batch Rename Torrented Movies and TV Shows

Batch rename torrented movies and TV shows

Rename is a *nix tool to rename files according to modification rules specified on the command line.

The examples below show how to rename common naming schemes from toreented moveies and tv shows in the way that Plex can parse to gather metadata. The examples all currently use the -n flag to do a dry run and only print out what the files would be renamed to. Remove the flag to actually overwrite the filename.

Rename TV Shows

Example

'Modern.Family.S05E01.720p.5.1Ch.Web-DL.ReEnc-DeeJayAhmed.mkv' --> 'Modern Family - s05e01.mkv'

'Modern.Family.S05E01.720p.5.1Ch.Web-DL.ReEnc-DeeJayAhmed.srt' --> 'Modern Family - s05e01.eng.srt'

rename -vn -S '.' ' ' -e 's/(.*?)\W+[Ss](\d{2})[Ee](\d{2}).*(.{3})/$1 - s$2e$3.$4/' *.(mp4|mkv|avi)
rename -vn -S '.' ' ' -e 's/(.*?)\W+[Ss](\d{2})[Ee](\d{2}).*(.{3})/$1 - s$2e$3.eng.$4/' *.srt

Rename Movies

Example

Creates subdirectory for each movie so that Plex can more easily associate subtitles

'Swiss.Family.Robinson.1960.1080p.BluRay.x264.YIFY.mp4' --> 'Swiss Family Robinson (1960)/Swiss Family Robinson (1960).mp4'

'Swiss.Family.Robinson.1960.1080p.BluRay.x264.YIFY.srt' --> 'Swiss Family Robinson (1960)/Swiss Family Robinson (1960).eng.srt'

rename -vn -S '.' ' ' -e 's/(.*?)\W+(\d{4}).*(.{3})/$1 ($2)\/$1 ($2).$3/' *.(mp4|mkv|avi)
rename -vn -S '.' ' ' -e 's/(.*?)\W+(\d{4}).*(.{3})/$1 ($2)\/$1 ($2).eng.$3/' *.srt
Copy link

ghost commented Oct 23, 2015

kikel emelni, és lekel írni,,?

@adamwalz
Copy link
Author

@beni05 Nem értem. Beszélsz angolul?

Copy link

ghost commented Oct 25, 2015

My name doesn't show up on GitHub Enterprise

If the email used in a commit matches a verified GitHub Enterprise user account, the account's username is used, instead of the username set by Git.

New commits aren't using the right name

If git config user.name reports the correct username for the repository you're viewing, but your commits are using the wrong name, !!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment