Page 1 of 1
Keep everything that's not already in the new name?
Posted: 19 Mar 2016, 21:32
by fluxtendu
Hi,
My sample files are:
- 11.22.63.S01E04.WEBRip.XviD-FUM[ettv].avi
11.22.63.105.hdtv-lol[ettv].mp4
and I would like to get :
- /11.22.63/S01/11.22.63 - S01E04 - episode title (WEBRip.XviD-FUM[ettv]).avi
/11.22.63/S01/11.22.63 - S01E05 - another episode title (hdtv-lol[ettv]).mp4
The first part is easy to achieve with this
Code: Select all
/{n}/{episode.special ? 'Special' : 'S'+s.pad(2)}/{n} - {episode.special ? 'S00E'+special.pad(2) : s00e00} - {t}
But how to get the part in bold that corresponds to everything that's not already in the new name?
(I know that I can use {group} {vc}, etc... But I want to keep everything, not just those that match)
Thank you.
Re: Keep everything that's not already in the new name?
Posted: 19 Mar 2016, 22:12
by rednoah
You could try something like this:
Or this:
Either way, you'll have to tweak the regex patterns.
Re: Keep everything that's not already in the new name?
Posted: 20 Mar 2016, 13:08
by fluxtendu
Thank you!
The first one is what I was looking for... I ended up with:
Code: Select all
{fn.after(/[- ._](S\d+E\d+|\d{3,4}|\d+x\d+)[- ._]/)}
That match anything after those: ".S02E04." " 1x05 " "-108-" "_01X07_" ".s3e5-" etc...
But my quest to find the perfect naming scheme gave me two more questions:
1) Can I use tags (e.g. {n},{t}) in regular expressions? Something like
My tests were not successful, but maybe it's me...
2) In my sample names from the first post, there's two {group}, and filebot always give me the second one: ettv, how can I get the first one? Is it possible to not parse specific part of a name?
Re: Keep everything that's not already in the new name?
Posted: 20 Mar 2016, 19:02
by rednoah
1.
Outer {...}
(FileBot Groovy expressions) have completely different semantics from inner {...}
(Groovy closure).
You want:
@see
viewtopic.php?f=5&t=1895
2.
{group} will pick the last one. If combinations like
FUM[ettv] where to be added to the groups list it could probably work.
@see
viewtopic.php?f=5&t=4
Re: Keep everything that's not already in the new name?
Posted: 22 Mar 2016, 04:38
by fluxtendu
1) Yes I was looking for replaceAll(n, '')
but do you have something like:
to replace the year?
I try to adapt the code for movies, but the year is not always in the source name and I don't have other unique separator, so I imagined something like this:
Code: Select all
/{n} ({y})/{n} - {y}{' CD'+pi}{'.'+lang}{' ('+fn.replaceAll(n.space('.'), '').replaceAll(n, '').replaceAll(y, '').+')'}
(I also need to remove the first character if it's one of these character: ._ - but I will try later...)
2) I do not want that the combination of groups is added and recognized, but that the group [ettv] is excluded to keep only the other part.
The best I have found is this:
Code: Select all
/{n}/{episode.special ? 'Special' : 'S'+s.pad(2)}/{n} - {episode.special ? 'S00E'+special.pad(2) : s00e00} - {t} {"("+fn.after(/[- ._](S\d+E\d+|\d{3,4}|\d+x\d+)[- ._]/).replaceAll("\\[ettv\\]", '')+")"}
But a personal exclusion list would be helpful to avoid growing code... (Ideally used before parsing)
Re: Keep everything that's not already in the new name?
Posted: 22 Mar 2016, 06:59
by rednoah
1.
If it doesn't work already, it's probably because replaceAll wants a String and y gives you an Integer.
This will work:
fn.replaceAll(y as String, '')
Replace leading ._ characters:
fn.replaceAll(/^[._]+/, '')
2.
You'll need your own group matching logic then. You can use text files. FileBot gives you the csv(path) or readLines(path) functions to do that easily.