Page 1 of 1

3D Renaming According to FileName

Posted: 29 Jan 2016, 11:15
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.

Re: 3D Renaming According to FileName

Posted: 29 Jan 2016, 14:40
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)')}

Re: 3D Renaming According to FileName

Posted: 29 Jan 2016, 16:46
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.

Re: 3D Renaming According to FileName

Posted: 29 Jan 2016, 18:34
by rednoah
Here's what {s3d} will match in the future:
http://www.regexr.com/3cmih

Thanks for the test data. ;)

Re: 3D Renaming According to FileName

Posted: 30 Jan 2016, 09:09
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:

Re: 3D Renaming According to FileName

Posted: 30 Jan 2016, 10:48
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 ヾ(@⌒ー⌒@)ノ

Re: 3D Renaming According to FileName

Posted: 30 Jan 2016, 15:01
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}])? ;)

Re: 3D Renaming According to FileName

Posted: 01 Feb 2016, 17:38
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?

Re: 3D Renaming According to FileName

Posted: 01 Feb 2016, 18:29
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.