file,path replace

Any questions? Need some help?
Post Reply
Ztrust
Posts: 69
Joined: 21 Dec 2013, 17:04

file,path replace

Post by Ztrust »

hey rednoah
I am still strugling with this
http://www.filebot.net/forums/viewtopic ... 063#p11942

Code: Select all

{n} ({y}) {'['+file.path.replaceAll(/(?i)(?<!^).dc/, 'directors cut').matchAll(/UNRATED|REMASTERED|EXTENDED|UNCUT|DIRECTORS.CUT|THEATRICAL.CUT/).join('][').upperInitial().lowerTrail()+']'}
rednoah wrote:Do you know the value of file.path? Let's try!

Code: Select all

{file.path}
Oh! It's the full path! So it starts with / and not D, I guess we have to check for /DC then.
I cant figure out how to get the /DC in without bracking the format ?

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

Re: file,path replace

Post by rednoah »

What do you have?
What do you want?

With examples please.
:idea: Please read the FAQ and How to Request Help.
Ztrust
Posts: 69
Joined: 21 Dec 2013, 17:04

Re: file,path replace

Post by Ztrust »

Hi
let me explain
I have this format with file.path replace because I noticed I missed alot of directors cut tag because it was listed as DC in the file name and not folder name
full format

Code: Select all

D:/Movies/{genres.contains('Animation') ? 'Cartoons' : info.SpokenLanguages[0] ==~ /(no|da|sv|nb)/ ? 'Nordic Movies' : n.replaceFirst(/^(?i)(The)\s(.+)/, /$2, $1/)[0] =~ /^(?i)[0-9]/ ? '0-9' : n.replaceFirst(/^(?i)(The)\s(.+)/, /$2, $1/)[0] =~ /^(?i)[a-d]/ ? 'ABCD' : n.replaceFirst(/^(?i)(The)\s(.+)/, /$2, $1/)[0] =~ /^(?i)[e-h]/ ? 'EFGH' : n.replaceFirst(/^(?i)(The)\s(.+)/, /$2, $1/)[0] =~ /^(?i)[i-l]/ ? 'IJKL' : n.replaceFirst(/^(?i)(The)\s(.+)/, /$2, $1/)[0] =~ /^(?i)[m-p]/ ? 'MNOP' : n.replaceFirst(/^(?i)(The)\s(.+)/, /$2, $1/)[0] =~ /^(?i)[q-t]/ ? 'QRST' : n.replaceFirst(/^(?i)(The)\s(.+)/, /$2, $1/)[0] =~ /^(?i)[u-å]/ ? 'UVWYXZ' : '~'}/{collection.replaceFirst(/^(?i)(The)\s(.+)/,/$2, $1/).replaceAll(/[:|]/, ".").replaceAll(/[?]/, "!").replaceAll(/(?i)Collection/).trim()+' (Collection)/'}{info.SpokenLanguages[0] ==~ /(no|da|sv|nb)/ ? primaryTitle.upperInitial().replaceAll(/[:|]/, ".").replaceAll(/[?]/, "!") : n.replaceFirst(/^(?i)(The)\s(.+)/,/$2, $1/).replaceAll(/[:|]/, ".").replaceAll(/[?]/, "!")} ({y}){' ['+file.path.replaceAll(/(?i)theatrical/, '$0 Cut').replaceAll(/(?i)director's.cut|.dc/, 'Directors cut').matchAll(/extended|uncensored|remastered|ultimate.cut|unrated|uncut|Theatrical.Cut|imax|final.cut|Theatrical.edition|3d|directors.cut|special.edition/)*.upperInitial()*.lowerTrail().sort().unique().join('] [').replaceAll(/[._´]/," ") + ']'}/{info.SpokenLanguages[0] ==~ /(no|da|sv|nb)/ ? primaryTitle.upperInitial().replaceAll(/[:|]/, ".").replaceAll(/[?]/, "!") : n.replaceAll(/[:|]/, ".").replaceAll(/[?]/, "!")} ({y}){' ['+file.path.replaceAll(/(?i)theatrical/, '$0 Cut').replaceAll(/(?i)director's.cut|.dc/, 'Directors cut').matchAll(/extended|uncensored|remastered|ultimate.cut|unrated|uncut|Theatrical.Cut|imax|final.cut|Theatrical.edition|3d|directors.cut|special.edition/)*.upperInitial()*.lowerTrail().sort().unique().join('] [').replaceAll(/[._´]/," ") + ']'}{' '+[c{source} ?: 'BDrip']}{"."+lang}

Replace part

Code: Select all

{' ['+file.path.replaceAll(/(?i)theatrical/, '$0 Cut').replaceAll(/(?i)director's.cut|.dc/, 'Directors cut').matchAll(/extended|uncensored|remastered|ultimate.cut|unrated|uncut|Theatrical.Cut|imax|final.cut|Theatrical.edition|3d|directors.cut|special.edition/)*.upperInitial()*.lowerTrail().sort().unique().join('] [').replaceAll(/[._´]/," ") + ']'}
and it works for the most part exept that it adds Directors Cut to DC Showcase. Like so DC showcase Catwoman Directors Cut
User avatar
rednoah
The Source
Posts: 22995
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: file,path replace

Post by rednoah »

I'd solve the problem with Lookahead and Lookbehind:
http://www.regular-expressions.info/lookaround.html

e.g.

Code: Select all

{'DC Foobar DC'.replaceAll(/(?<=\W)DC(?!\w)/, 'Directors Cut')}
:idea: Please read the FAQ and How to Request Help.
Post Reply