Any way to replace/add ONLY s00e00 to the filename?

All about user-defined episode / movie format expressions
Post Reply
enchained
Posts: 5
Joined: 01 Jan 2018, 00:28

Any way to replace/add ONLY s00e00 to the filename?

Post by enchained » 01 Jan 2018, 00:35

For example, if I have

Code: Select all

Downton.Abbey.Christmas.Special.720p.Bluray.AC32.0.2011.720p.bluray.shortbrehd
I'd like to get

Code: Select all

Downton.Abbey.S00E02.Christmas.Special.720p.Bluray.AC32.0.2011.720p.bluray.shortbrehd
And if I have

Code: Select all

Downton.Abbey.s02e09e10.1080p.BDRip.2xRus.Eng.mkv
I'd like to get

Code: Select all

Downton.Abbey.S00E02.1080p.BDRip.2xRus.Eng.mkv
For now I just copy the filename and then replace the episode info to {s00e00}.
Is there a universal one-liner expression for those cases? I really like to keep all release info in the filename untouched, but want Plex to detect it properly.

User avatar
rednoah
The Source
Posts: 16123
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Any way to replace/add ONLY s00e00 to the filename?

Post by rednoah » 01 Jan 2018, 09:02

If the filename is misleading, then auto-matching may not work.

You can always manually match the file with the correct episode item:
https://www.youtube.com/watch?v=btNSv7AnMMw
:idea: Please read the FAQ and How to Request Help.

enchained
Posts: 5
Joined: 01 Jan 2018, 00:28

Re: Any way to replace/add ONLY s00e00 to the filename?

Post by enchained » 01 Jan 2018, 13:04

Thanks, but I wasn't talking about matching at all, I can match just fine manually using the Episodes tab. I was talking about expression that will give me desired result for both cases (if such expression is possible) AFTER I match the episode manually.

kim
Power User
Posts: 756
Joined: 15 May 2014, 16:17

Re: Any way to replace/add ONLY s00e00 to the filename?

Post by kim » 01 Jan 2018, 18:04

I don't think there is any All-in-1 way.
Downton.Abbey.Christmas.Special.720p.Bluray.AC32.0.2011.720p.bluray.shortbrehd
this is detected as s00e11, so rename to:
Downton.Abbey.Christmas.at.Downton Abbey.720p.Bluray.AC32.0.2011.720p.bluray.shortbrehd
then you can use:

Code: Select all

{def tmp = n.space('.'); tmp+'.'+s00e00+fn.after(tmp)}
else:
You will need to do a complex regex

User avatar
rednoah
The Source
Posts: 16123
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Any way to replace/add ONLY s00e00 to the filename?

Post by rednoah » 01 Jan 2018, 19:23

If you got the correct match, then the expression format can transform that information into any kind of file path you want with arbitrarily complex logic.

But I'm not sure what you want. Could you give me more examples of what you are trying to do, what you have tried, and where you have trouble? Is it about retaining bits and pieces of the original filename?

:?: If you have S02E09E10 but want S00E02 then you need to match that S02E09E10 file manually to the S00E02 episode... but the rest is just up to the format as usual.
:idea: Please read the FAQ and How to Request Help.

kim
Power User
Posts: 756
Joined: 15 May 2014, 16:17

Re: Any way to replace/add ONLY s00e00 to the filename?

Post by kim » 01 Jan 2018, 19:57

I think you are looking for something like this:

Code: Select all

{
def epi = any{fn.match(/S\d+E\d+-?E\d+|S\d+E\d+/)}{};
def withEpi = (epi != null ? n+' '+epi : n).space('.')
def withOutEpi = n.space('.')
epi != null ? (fn.before(fn.after(withOutEpi))+'.'+s00e00+fn.after(withEpi)) : (fn.before(fn.after(withOutEpi))+'.'+s00e00+fn.after(withOutEpi));
}}
but this will only work if Filebot match correct
Downton.Abbey.s02e09e10.1080p.BDRip.2xRus.Eng.mkv
should be
Downton.Abbey.s00e01e02.1080p.BDRip.2xRus.Eng.mkv
btw: I used some time to make this just for you ;)

enchained
Posts: 5
Joined: 01 Jan 2018, 00:28

Re: Any way to replace/add ONLY s00e00 to the filename?

Post by enchained » 01 Jan 2018, 20:16

rednoah wrote:
01 Jan 2018, 19:23
Could you give me more examples of what you are trying to do, what you have tried, and where you have trouble? Is it about retaining bits and pieces of the original filename?
Yes, it's exactly about "retaining bits and pieces of the original filename". I don't care if the episode original filename can't be auto-matched, I match it manually in such cases, finding the episodes in the Episodes section, and transferring them "to the right side" of the Rename. I'm worried about renaming here. So, I have some scene-named special, plex ignores it completely, then I go and match it to the TVDB in the filebot (auto or manually). Then I have my files on the left side and their correct matches on the right side. I just need the expression that won't just change it to some genric "Show Name - s00e00 - Episode Title" or some other custom unified format. I want to retain all original filename parts except for season and episode (for plex detection). Other example would be "Adventure time" - scene released same episodes with 8 and 9 season in the filename, and different episodes numbering in each case (cause of confusion where one season ends and other begins). I want to match them manually to the TVDB order, and then rename only the s00e00 parts in them, leaving everything else untouched and in the same order - audio quality, languages, release group, codecs, quality, and whatever else someone decided to put there (I know I can get some of that stuff from the expression variables, but that's not what I want).

enchained
Posts: 5
Joined: 01 Jan 2018, 00:28

Re: Any way to replace/add ONLY s00e00 to the filename?

Post by enchained » 01 Jan 2018, 20:36

kim wrote:
01 Jan 2018, 19:57
btw: I used some time to make this just for you ;)
Thank you very much! I'll try that! I had a feeling those "before" and "after" functions will come useful for my case, but the docs examples weren't enough to figure out how to conjure something so complex for me.

I'm a little confused about multi-line expressios though. I didn't even knew it's possible describe such algorithms with variables in filebot expression format. Are they supposed to go into the same expression field in the graphical interface? Cause mine just says Syntax error: expected EOF, but found 'def'. Or should I use it as a script for filebot CLI? I thought they were of a different syntax.

kim
Power User
Posts: 756
Joined: 15 May 2014, 16:17

Re: Any way to replace/add ONLY s00e00 to the filename?

Post by kim » 01 Jan 2018, 20:44

same as a 1 liner

Code: Select all

{def epi = any{fn.match(/S\d+E\d+-?E\d+|S\d+E\d+/)}{};def withEpi = (epi != null ? n+' '+epi : n).space('.');def withOutEpi = n.space('.');epi != null ? (fn.before(fn.after(withOutEpi))+'.'+s00e00+fn.after(withEpi)) : (fn.before(fn.after(withOutEpi))+'.'+s00e00+fn.after(withOutEpi))}
you can use it in GUI and CLI (you may need to escape some '\')

use the "Select all" and make sure there is NO extra data pasted in the format

enchained
Posts: 5
Joined: 01 Jan 2018, 00:28

Re: Any way to replace/add ONLY s00e00 to the filename?

Post by enchained » 01 Jan 2018, 22:06

Works like magic! Thanks again for finding time to look into it.

Post Reply