3D Renaming According to FileName

Running FileBot from the console, Groovy scripting, shell scripts, etc
Post Reply
User avatar
LysanderM
Donor
Posts: 26
Joined: 20 Feb 2015, 12:56

3D Renaming According to FileName

Post by LysanderM »

Hi,

Code: Select all

FileBot 4.6.1 (r3315) / Java(TM) SE Embedded Runtime Environment 1.8.0_71 (headless)
I'm using a bash script in my Synology DS115j.
Image
An example of the output result is shown with red arrow.
As you may have noticed, the output of the parameter $moviesStringOnly2 is on line 107.

The filenames to be renamed can be like

Code: Select all

Journey.to.the.Center.of.the.Earth.3D.2008.1080p.HSBS.x264
Journey.to.the.Center.of.the.Earth.3D.2008.1080p.HOU.x264
Journey.to.the.Center.of.the.Earth.3D.2008.1080p.H-OU.x264
Journey to the Center of the Earth 2 (2012) [3D] [SBS] [1080p]
Journey to the Center of the Earth 2 (2012) [3D] [H-SBS] [1080p]
Journey to the Center of the Earth 2 (2012) [3D] [H-OU] [1080p]
Journey.to.the.Center.of.the.Earth.2.2012.3D.SBS.1080p.BluRay.x264
Journey.to.the.Center.of.the.Earth.2.2012.3D.HOU.1080p.BluRay.x264
etc.

The script works just fine. The only problem is, in my media server software Plex, it detects 3D movies by their filename if the endings are just like this one:
Image
Otherwise I just can't switch to mode 3D on my Samsung TV's Plex app.
User avatar
rednoah
The Source
Posts: 23953
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: 3D Renaming According to FileName

Post by rednoah »

The next release will have the new {s3d} binding, but in the meanwhile you can match it from the filename with your own pattern:

Code: Select all

{fn.match('3D[^\\p{Alnum}]?(?:H|HALF|F|FULL)?[^\\p{Alnum}]?(?:SBS|TAB|OU)')}
:idea: Please read the FAQ and How to Request Help.
User avatar
LysanderM
Donor
Posts: 26
Joined: 20 Feb 2015, 12:56

Re: 3D Renaming According to FileName

Post by LysanderM »

Well that was fast. :)

I haven't tested it yet, but I'm pretty sure it's going to work. Your next cup of coffee is on the house. ;)

Appreciated.

BTW {s3d} seems pretty cool. I hope it's Plex compatible or maybe i can define a parameter for it.
User avatar
rednoah
The Source
Posts: 23953
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: 3D Renaming According to FileName

Post by rednoah »

Here's what {s3d} will match in the future:
http://www.regexr.com/3cmih

Thanks for the test data. ;)
:idea: Please read the FAQ and How to Request Help.
User avatar
LysanderM
Donor
Posts: 26
Joined: 20 Feb 2015, 12:56

Re: 3D Renaming According to FileName

Post by LysanderM »

Code: Select all

“HSBS”, “H-SBS” or “Half-SBS” for Side-By-Side content 
“HTAB”, “H-TAB”, “Half-TAB” or “HALF-OU” for Top-And-Bottom/ Over-Under content 
An update for the first part FYI: "Half"

Source #1
Source #2

Your Regex is superb by the way. I just can't read them still, I mean I can't write it on my own from the beginning... :cry:
User avatar
LysanderM
Donor
Posts: 26
Joined: 20 Feb 2015, 12:56

Re: 3D Renaming According to FileName

Post by LysanderM »

I've tried, and concluded with a syntax exception.

Code: Select all

moviesStringOnly2="$moviesFolder/$moviesFormatString/$moviesFormatString"$fileBot3DRegex
moviesStringOnly2Alternatively="$moviesFolder/$moviesFormatString/$moviesFormatString$fileBot3DRegex"
Actual output of one of my $moviesStringOnly2 parameter

Code: Select all

/volume1/video/movies/{n.space('.')}.({y}){'.'+genres[0][0..2].upperInitial()}{genres[1][0..2].upperInitial()}{genres[2][0..2].upperInitial()}.{rating}/{n.space('.')}.({y}){'.'+genres[0][0..2].upperInitial()}{genres[1][0..2].upperInitial()}{genres[2][0..2].upperInitial()}.{rating}{any{'.'+fn.match('(?:H|Half|HALF|F|FULL)([^\p{Alnum}])?(?:SBS|TAB|OU)')}{''}}
All of my testings

Code: Select all

fileBot3DRegex="{any{'.'+fn.match('(?:H|Half|HALF|F|FULL)([^\p{Alnum}])?(?:SBS|TAB|OU)')}{''}}"
fileBot3DRegex=".{fn.match('3D[^\\p{Alnum}]?(?:H|Half|HALF|F|FULL)?[^\\p{Alnum}]?(?:SBS|TAB|OU)')}"
fileBot3DRegex=".{fn.match('(?:H|HALF|F|FULL)[^\\p{Alnum}]?(?:SBS|TAB|OU)')}"
fileBot3DRegex="{any{'.'+fn.match('(?:H|Half|HALF|F|FULL)[^\\p{Alnum}]?(?:SBS|TAB|OU)')}{''}}" 
fileBot3DRegex="{any{'.'+fn.match('(?:H|Half|HALF|F|FULL)([^\\p{Alnum}])?(?:SBS|TAB|OU)')}{''}}"
fileBot3DRegex="{any{'.'+fn.match('(?:H|Half|HALF|F|FULL)([^\p{Alnum}])?(?:SBS|TAB|OU)')}{''}}"
Without quotation marks

Code: Select all

{any{'.'+fn.match('(?:H|Half|HALF|F|FULL)([^\p{Alnum}])?(?:SBS|TAB|OU)')}{''}}
.{fn.match('3D[^\\p{Alnum}]?(?:H|Half|HALF|F|FULL)?[^\\p{Alnum}]?(?:SBS|TAB|OU)')}
.{fn.match('(?:H|HALF|F|FULL)[^\\p{Alnum}]?(?:SBS|TAB|OU)')}
{any{'.'+fn.match('(?:H|Half|HALF|F|FULL)[^\\p{Alnum}]?(?:SBS|TAB|OU)')}{''}}
{any{'.'+fn.match('(?:H|Half|HALF|F|FULL)([^\\p{Alnum}])?(?:SBS|TAB|OU)')}{''}}
{any{'.'+fn.match('(?:H|Half|HALF|F|FULL)([^\p{Alnum}])?(?:SBS|TAB|OU)')}{''}}
Same exception for all.

Code: Select all

ScriptException: SyntaxError: unexpected char: '\'
Done ヾ(@⌒ー⌒@)ノ
User avatar
rednoah
The Source
Posts: 23953
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: 3D Renaming According to FileName

Post by rednoah »

Be careful with \x escape sequences:

Code: Select all

$ echo "[^\\p{Alnum}]"
[^\p{Alnum}]
The shell will interpret the \ same as Groovy/Java String. So you might need \\\\ to get \ in the Regex in the Java String in the bash String. Maybe avoiding all \ would be easier. :D

Just do (.)? instead of ([^\p{Alnum}])? ;)
:idea: Please read the FAQ and How to Request Help.
User avatar
LysanderM
Donor
Posts: 26
Joined: 20 Feb 2015, 12:56

Re: 3D Renaming According to FileName

Post by LysanderM »

Well I've got it, thanks a lot.

http://regexr.com/3cn1k

According to the latest link, where is the problem about case insensivity?
User avatar
rednoah
The Source
Posts: 23953
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: 3D Renaming According to FileName

Post by rednoah »

The link is just for fun. The FileBot match function is has CASE_INSENSITIVE and UNICODE_CHARACTER_CLASS flags turned on by default.
:idea: Please read the FAQ and How to Request Help.
Post Reply