Renaming tv shows

A swapping-ground for Regular Expression syntax

Renaming tv shows

Postby larsl » Sat Jan 02, 2016 2:52 pm

I got the following TV show named convention on my hard drives that I ripped from my dvd's and downloaded metadata for:

The Office.S01E01.Pilot.mp4
The Office.S01E01.Pilot.nfo
The Office.S01E01.Pilot.en.srt
The Office.S01E01.Pilot-thumb.jpg
The Office.S01E02....
And so on...

I want to rename the files to this instead (to make it easier for my plex):

The Office - s01e01 - Pilot.mp4
The Office - s01e01 - Pilot.nfo
The Office - s01e01 - Pilot.en.srt
The Office - s01e01 - Pilot-thumb.jpg
The Office - s01e02 - ...
And so on

Is there any way to do the above rename some smart way?

Basically renaming .SxxExx. To - sxxexx -
larsl
 
Posts: 1
Joined: Sat Jan 02, 2016 9:58 am

Re: Renaming tv shows

Postby Renamer34 » Fri Jan 08, 2016 9:33 pm

Regex Match:
(.*)\.S(\d+)E(\d+)\.(.*)
Regex Replace:
\1 -s\2e\3- \4
Renamer34
 
Posts: 3
Joined: Fri Jan 08, 2016 8:21 pm

Re: Renaming tv shows

Postby DickyDck » Fri Dec 23, 2016 4:24 pm

Thanks for this! this works great for files that already have the Season and episode # in them. Is there a way to script it if they don't though? example

Original
ShowName 01.mkv
ShowName 02.mkv

Edited
Showname S01E01.mkv
Showname S01E02.mkv


not worried so much about the episode titles, just the numbers for the season and episode would be great. I started doing it manually for some of my tv shows in Plex, but 15 seasons of Bleach with some seasons having 20+ episodes... got tedious really quick. Any assistance is great, thanks in advance!
DickyDck
 
Posts: 10
Joined: Fri Dec 23, 2016 4:20 pm

Re: Renaming tv shows

Postby KenP » Fri Dec 23, 2016 4:44 pm

You'll need to change the series number (coloured red) to suit the series but otherwise this should work.

RegEx (1)
Match: (.*)(\d{2})
Replace: \1 S01E\2

Having said that, there may be a better way if you have the series number in the folder name.
KenP
 
Posts: 193
Joined: Sat Jul 30, 2016 11:25 am

Re: Renaming tv shows

Postby DickyDck » Fri Dec 23, 2016 5:06 pm

I can totally rename the folder! so lets add to the mix here...

example Original setup .

D:\ShowName S1\Showname 01.mkv
*everything in between
D:\ShowName S1\Showname 101.mkv


Ideal end result that Plex will like...


D:\ShowName S1\Showname S01E01.mkv
*everything in between
D:\ShowName S1\Showname S01E101.mkv


Not sure if I should rename the folder to something more descriptive like "d:\showname season01"

Thanks for your help!

~~Dick
DickyDck
 
Posts: 10
Joined: Fri Dec 23, 2016 4:20 pm

Re: Renaming tv shows

Postby KenP » Fri Dec 23, 2016 6:11 pm

But if you're got to rename the folders you're no better off because you're still going to need to rename the files :?
KenP
 
Posts: 193
Joined: Sat Jul 30, 2016 11:25 am

Re: Renaming tv shows

Postby DickyDck » Fri Dec 23, 2016 6:20 pm

Oh, i thought you had a better proposal if I had the series name in the folder name :p
DickyDck
 
Posts: 10
Joined: Fri Dec 23, 2016 4:20 pm

Re: Renaming tv shows

Postby DickyDck » Fri Dec 23, 2016 6:26 pm

Is there a glossary/tutorial/dictionary of how these match up to the filenames? trying to figure out what part = what part

RegEx (1)
Match: (.*)(\d{2})
Replace: \1 S01E\2

if I can figure out how this works I won't need to bug everyone so much :)
DickyDck
 
Posts: 10
Joined: Fri Dec 23, 2016 4:20 pm

Re: Renaming tv shows

Postby KenP » Fri Dec 23, 2016 6:28 pm

What I meant was that if you've already got the series number in the folder name you could possibly add it to the file names before using regex to rename the files, but if you've got to manually rename the folders anyway I don't see that you're any better off.
KenP
 
Posts: 193
Joined: Sat Jul 30, 2016 11:25 am

Re: Renaming tv shows

Postby KenP » Fri Dec 23, 2016 6:39 pm

DickyDck wrote:Is there a glossary/tutorial/dictionary of how these match up to the filenames? trying to figure out what part = what part

RegEx (1)
Match: (.*)(\d{2})
Replace: \1 S01E\2

if I can figure out how this works I won't need to bug everyone so much :)


In the Match:
(.*) is group 1 and captures everything up-to the 2 numbers which are the episode numbers.
(\d{2}) is group 2 and group and captures the episode 2 numbers.

In Replace:
\1 puts group 1 into the file name.
S01E puts S01E into the file name.
\2 puts group 2 into the file name.
KenP
 
Posts: 193
Joined: Sat Jul 30, 2016 11:25 am

Re: Renaming tv shows

Postby DickyDck » Fri Dec 23, 2016 9:26 pm

Score! thanks, I'll experiment tonight and see how badly I screw up my libraries :p
DickyDck
 
Posts: 10
Joined: Fri Dec 23, 2016 4:20 pm

Re: Renaming tv shows

Postby DickyDck » Sat Dec 24, 2016 11:01 pm

alrighty! so I'm semi figuring this out.

RegEx (1)
Match: (.*)(\d{2})
Replace: \1 S01E\2

Working great with double digit episodes, but with triple digit episodes it is not doing the same thing. I'm switching around some of the parameters but can't find the right combination. Can you assist? here is what I have been getting using the same above criteria..

Source
Showname 100.mkv

Edited using above
Showname 1 S05E00.mkv


So it isn't jumping to the right digit location, but I'm not making the proper adjustment to get the right effect. I'm sure it is something simple but my coding/scripting skills are not up to par...
DickyDck
 
Posts: 10
Joined: Fri Dec 23, 2016 4:20 pm

Re: Renaming tv shows

Postby DickyDck » Sat Dec 24, 2016 11:06 pm

Figured it out, I needed to switch around the "Match" criteria!!!!
DickyDck
 
Posts: 10
Joined: Fri Dec 23, 2016 4:20 pm

Re: Renaming tv shows

Postby KenP » Sat Dec 24, 2016 11:28 pm

I'm not sure what you mean about switching the match criteria around, but this works for me.

RegEx (1)
Match: (.*)\s((\d{3})|(\d{2}))
Replace: \1 S01E\2



If you want to separate the series number from the edition number I usually use a hyphen, but it's a matter of personal choice :wink:

Replace: \1 S01-E\2
KenP
 
Posts: 193
Joined: Sat Jul 30, 2016 11:25 am

Re: Renaming tv shows

Postby DickyDck » Sat Dec 24, 2016 11:32 pm

Oooh, I like the hyphen option! So what I ended up doing was this

Original
RegEx (1)
Match: (.*)(\d{2})
Replace: \1 S01E\2

Modified
RegEx (1)
Match: (.*)(\d{3})
Replace: \1 S01E\2


The Original was perfect until I hit the triple digit episodes, I'm not exactly sure the logic in using the "3" in place of the "2" but as I start another folder I will experiment. I see what you did with the pipe now and the double inner. This is starting to give me SQL flashback nightmares :p
DickyDck
 
Posts: 10
Joined: Fri Dec 23, 2016 4:20 pm

Next

Return to Regular Expressions


cron