Some questions regarding renaming

Any questions? Need some help?
justkidding
Posts: 38
Joined: 12 Oct 2015, 20:42

Some questions regarding renaming

Post by justkidding » 01 Mar 2020, 10:45

Hello,

I love Filebot and I am using it for a long time on my Synology NAS.
I would love to improve my renaming even more but I need some help for that.
At the moment I am using the following statement:

Code: Select all

/data/Movies/{az}/{collection}/{ny.UpperInitial()}/{n.upperInitial()} ({y})/{n.upperInitial()} ({y}) {fn.matchAll(/UHD|4K|MVC|framepacked|FSBS|HSBS|HOU|FOU/)} {source} {special} {tags} {vf} {vc} {hdr} {s3d} {aco} {channels} {audioLanguages} {subt}
I've deleted the seriesformat as it makes it easier to read and my questions only concern movies.

1.) I would like to integrate the dynamic localization binding ({localize[languages.first()].n : n}). But I still want to use the upperInitial()-Statement as well as the year. How would I do this?
2.) The {hdr}-Tag is working fine but I would like that all movies that are not hdr are tagged sdr. I already tried {any{hdr}{'SDR}} (gives only HDR if movie is HDR and nothing if movie is not HDR) and any{hdr}{'SDR'} (gives anyHDR if movie is HDR and any if movie is not HDR).
3.) The bindings {aco} and {channels} always give the information of the first audio stream found but I would like to get the information of the audio stream with the best quality found. Is this possible?
For example if I have a movie with the following audio streams
1.) German DTS-HD 5.1
2.) English Dolby TrueHD 7.1 Atmos
the two bindings give me "DTS-HD Master Audio 5.1" but I want "TrueHD+Atmos 7.1" as this is the best quality audio stream.

Your help is really appreciated.

Best regards,
justkidding

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

Re: Some questions regarding renaming

Post by rednoah » 01 Mar 2020, 11:12

1.
String.upperInitial() works for any String object:

Code: Select all

any{localize[languages[0]].ny}{ny}.upperInitial()

2.
This snippet is simple enough, so it can't not work, so if it indeed doesn't work, there's something else going on, on a higher level, making use not do what we think we're doing:

Code: Select all

any{hdr}{'SDR'}

3.
You can use {audio} to access all raw audio properties for all audio streams, but you'll have to figure out how to define "best quality" numerically in your code, to find the "best audio stream" according to your definition:
viewtopic.php?t=4285

e.g. find audio stream with the highest number of channels:

Code: Select all

{
	def a = audio.max{ it.Channels as int }
	a.Channels + 'ch.' + a.Format
}
:idea: Please read the FAQ and How to Request Help.

justkidding
Posts: 38
Joined: 12 Oct 2015, 20:42

Re: Some questions regarding renaming

Post by justkidding » 01 Mar 2020, 11:51

I guess I have a general problem with the statement "any".
If I do "any{localize[languages[0]].ny}{ny}.upperInitial()" or "any{hdr}{'SDR'}" it always adds the word "any" to the filename.
What could cause that?
That's my statement at the moment:
'movieFormat=/data/Movies/{az}/{collection}/{ny.UpperInitial()}/{n.upperInitial()} ({y})/any{localize[languages[0]].ny}{ny}.upperInitial() ({y}) {fn.matchAll(/UHD|4K|MVC|framepacked|FSBS|HSBS|HOU|FOU/)} {source} {special} {tags} {vf} {vc} any{hdr}{'SDR'} {s3d} {aco} {channels} {audioLanguages} {subt}'
as a result it gives the following file name:
anyGuardians of the Galaxy Vol. 2 (2017).upperInitial() [UHD, 4K] BluRay 2160p HEVC anyHDR DTS-HD High Resolution Audio 5.1 [deu, eng]
Is {localize[languages[0]]} the same as {localize[languages.first()].n}?
Or would it be "{localize[languages.first()].ny : ny}.upperInitial()" respectively "{localize[languages.first()].ny : ny}.upperInitial()"?

Regarding point 3.)
On the NAS in Filebot Node I do not find this option
:idea: Open FileBot Image ➔ Edit Format Image ➔ Change Sample Image ➔ Open MediaInfo Image
to check what possibilities I have with media info. Is it only possible with Windows?
Do i have to do the defining variable inside the movieFormat-statement or separately before the call of filebot?
For example can I just do it like this:
'movieFormat=/data/Movies/{az}/{collection}/{ny.UpperInitial()}/{n.upperInitial()} ({y})/any{localize[languages[0]].ny}{ny}.upperInitial() ({y}) {fn.matchAll(/UHD|4K|MVC|framepacked|FSBS|HSBS|HOU|FOU/)} {source} {special} {tags} {vf} {vc} any{hdr}{'SDR'} {s3d} {aco} {channels} {audioLanguages} {subt} {def a = audio.max{ it.Channels as int } a.Channels + 'ch.' + a.Format}'
Sorry, I don't get this yet.

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

Re: Some questions regarding renaming

Post by rednoah » 01 Mar 2020, 12:07

1.
This is a Groovy snippet:

Code: Select all

any{hdr}{'SDR'}
* This is Groovy code.

This is how you write a Format Expression that executes a given Groovy snippet:

Code: Select all

{ any{hdr}{'SDR'} }
* This is not Groovy code. The outermost {...} are interpreted away the by the Format engine.

:idea: any is just another function, just like upperInitial is just another method.


3.
You'll want to prototype your format with the FileBot Desktop application:
https://www.filebot.net/naming.html

:idea: Once you're happy with your format expression, and have sufficiently tested it on your Desktop, then and only then, would you copy & paste the format into FileBot Node. Prototyping a new format within FileBot Node would be unnecessarily difficult.
:idea: Please read the FAQ and How to Request Help.

justkidding
Posts: 38
Joined: 12 Oct 2015, 20:42

Re: Some questions regarding renaming

Post by justkidding » 01 Mar 2020, 12:51

Okay, understood.
I will use the desktop application to check if everything is working there.
But where do I do the defining of the variable? Where in my statement do I have to put this snippet

Code: Select all

{
	def a = audio.max{ it.Channels as int }
	a.Channels + 'ch.' + a.Format
} 
?

Can you please check if the expression {audio.Format_AdditionalFeatures} is working correctly?
Media Info gives me the following information:
Format_AdditionalFeatures XLL X
but the name of the file does not contain "XLL X". Instead it contains nothing.
According to https://github.com/MediaArea/MediaInfo/issues/286 the information "Format_AdditionalFeatures" should be used to distinguish between DTS, DTS:X as well as TrueHD with Atmos and just TrueHD.
I am just testing with this statement

Code: Select all

{ any{localize[languages[0]].ny}{ny}.upperInitial() } {audio.Format_AdditionalFeatures} {audio.language}
in the desktop application.

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

Re: Some questions regarding renaming

Post by rednoah » 01 Mar 2020, 16:03

1.
{...} is evaluated, and yields a value. Where do you want that value to be? You decide. That's where you put the {...} in the format.

Image



2.
I've tried with one sample file at hand though, and {audio[0].FormatAdditionalFeatures} yields LC. Note that not all properties are going to be available for all files. Each file is different.

Please use the MediaInfo Inspector to inspect which properties are available for given file:
viewtopic.php?t=4285

Image
:idea: Please read the FAQ and How to Request Help.

justkidding
Posts: 38
Joined: 12 Oct 2015, 20:42

Re: Some questions regarding renaming

Post by justkidding » 01 Mar 2020, 16:33

I've used the desktop application for testing now.
With this I've build the following expression which works great:

Code: Select all

{az}/{collection}/{any{localize[languages[0]].n} {n}.upperInitial() } ({y})/{any{localize[languages[0]].ny}{ny}.upperInitial() } {tags} {source} {vc} {vf} { any{hdr}{'SDR'} }  
{ def bestaudio = audio.max{ it.Channels as int } 
  bestaudio.Format_additionalfeatures + ' ' + bestaudio.language + ' ' 
} 
{ audio.groupBy{ it.Language }.collect{ k, v-> v.size() > 1 ? v.size() + k : k } } 
{fn.matchAll(/UHD|4K|MVC|framepacked/)} {s3d} {subt}
Now I am trying to transfer this statement to my Synology NAS.
On the NAS I am using a .sh script.
My script looks like this now:

Code: Select all

/volume1/@appstore/filebot/filebot.sh -script 'fn:amc' --action 'test' '/volume1/data' --output /volume1/03_Filme -non-strict --conflict auto --lang en --def 'seriesFormat=/volume1/03_Filme/02 Serien/{az}/{n}/{episode.special ? '\''Special'\'' : '\''Staffel '\''+s}/{n} - {episode.special ? '\''S00E'\''+special.pad(2) : s00e00} - {t} {vf} { any{hdr}{'SDR'} } {aco} {channels} {audioLanguages} {subt}' 'movieFormat=/volume1/03_Filme/01 Movies/{az}/{collection}/{any{localize[languages[0]].n} {n}.upperInitial() } ({y})/{any{localize[languages[0]].ny}{ny}.upperInitial() } {tags} {source} {vc} {vf} { any{hdr}{'SDR'} }  
{ def bestaudio = audio.max{ it.Channels as int } 
  bestaudio.Format_AdditionalFeatures + ' ' + bestaudio.language + ' ' 
} 
{ audio.groupBy{ it.Language }.collect{ k, v-> v.size() > 1 ? v.size() + k : k } } 
{fn.matchAll(/UHD|4K|MVC|framepacked/)} {s3d} {subt}' 'skipExtract=y' 'subtitles=ger'  'excludeList=.excludes' --log info --log-file '/volume1/03_Filme/Filebotlogs/filebot.log'
It gives me the following error:

Code: Select all

Illegal Argument: java.nio.file.NoSuchFileException: /usr/syno/synoman/webapi/ + bestaudio.language +  ( + bestaudio.language + )
Illegal Argument: java.nio.file.NoSuchFileException: /usr/syno/synoman/webapi/ 
} 
{ audio.groupBy{ it.Language }.collect{ k, v-> v.size() > 1 ? v.size() + k : k } } 
{fn.matchAll(/UHD|4K|MVC|framepacked/)} {s3d} {subt} ( 
} 
{ audio.groupBy{ it.Language }.collect{ k, v-> v.size() > 1 ? v.size() + k : k } } 
{fn.matchAll(/UHD|4K|MVC|framepacked/)} {s3d} {subt})
Illegal Argument: java.nio.file.NoSuchFileException: /usr/syno/synoman/webapi/skipExtract=y (skipExtract=y)
Illegal Argument: java.nio.file.NoSuchFileException: /usr/syno/synoman/webapi/subtitles=ger (subtitles=ger)
Illegal Argument: java.nio.file.NoSuchFileException: /usr/syno/synoman/webapi/excludeList=.excludes (excludeList=.excludes)
Argument[1]: File does not exist:  + bestaudio.language + 
Argument[2]: File does not exist:  
} 
{ audio.groupBy{ it.Language }.collect{ k, v-> v.size() > 1 ? v.size() + k : k } } 
{fn.matchAll(/UHD|4K|MVC|framepacked/)} {s3d} {subt}
Argument[3]: File does not exist: skipExtract=y
Argument[4]: File does not exist: subtitles=ger
Argument[5]: File does not exist: excludeList=.excludes
ScriptException: SyntaxError: missing token: }
ScriptException: SyntaxError: missing token: }
Finished without processing any files 
I guess it is because the script cannot handle the new lines / spaces. But if I write everything in one line I get this error:

Code: Select all

Illegal Argument: java.nio.file.NoSuchFileException: /usr/syno/synoman/webapi/ + bestaudio.language +  ( + bestaudio.language + )
Illegal Argument: java.nio.file.NoSuchFileException: /usr/syno/synoman/webapi/ } { audio.groupBy{ it.Language }.collect{ k, v-> v.size() > 1 ? v.size() + k : k } } {fn.matchAll(/UHD|4K|MVC|framepacked/)} {s3d} {subt} ( } { audio.groupBy{ it.Language }.collect{ k, v-> v.size() > 1 ? v.size() + k : k } } {fn.matchAll(/UHD|4K|MVC|framepacked/)} {s3d} {subt})
Illegal Argument: java.nio.file.NoSuchFileException: /usr/syno/synoman/webapi/skipExtract=y (skipExtract=y)
Illegal Argument: java.nio.file.NoSuchFileException: /usr/syno/synoman/webapi/subtitles=ger (subtitles=ger)
Illegal Argument: java.nio.file.NoSuchFileException: /usr/syno/synoman/webapi/excludeList=.excludes (excludeList=.excludes)
Argument[1]: File does not exist:  + bestaudio.language + 
Argument[2]: File does not exist:  } { audio.groupBy{ it.Language }.collect{ k, v-> v.size() > 1 ? v.size() + k : k } } {fn.matchAll(/UHD|4K|MVC|framepacked/)} {s3d} {subt}
Argument[3]: File does not exist: skipExtract=y
Argument[4]: File does not exist: subtitles=ger
Argument[5]: File does not exist: excludeList=.excludes
ScriptException: SyntaxError: missing token: }
ScriptException: SyntaxError: missing token: }
Finished without processing any files
Are there differences in the syntax between windows and Linux?

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

Re: Some questions regarding renaming

Post by rednoah » 01 Mar 2020, 16:50

What happens if you use '...' to escape an argument value, but then also use '...' inside that argument value? Yes, that's what happens. The shell will pass complete gibberish on to filebot which is then rightly confused.


:arrow: Please read Cmdline and Argument Passing for details.


:idea: Use the @file syntax for reading command-line arguments from external text files so you don't have to worry about any of that. ;)
:idea: Please read the FAQ and How to Request Help.

justkidding
Posts: 38
Joined: 12 Oct 2015, 20:42

Re: Some questions regarding renaming

Post by justkidding » 01 Mar 2020, 18:14

@file_syntax is awesome - it really helped and solved some of my problems.
For example any{HDR}{'SDR'} is working now :D.
But I am still struggling with this part

Code: Select all

 { def bestaudio = audio.max{ it.Channels as int } 
  bestaudio.Format_AdditionalFeatures + ' ' + bestaudio.language + ' ' }  
Inside my argument file I now have the following format:

Code: Select all

 movieFormat=/volume1/03_Filme/01 Movies/{az}/{collection}/{any{localize[languages[0]].n} {n}.upperInitial() } ({y})/{any{localize[languages[0]].ny}{ny}.upperInitial() } {tags} {source} {vc} {vf} { any{hdr}{'SDR'} } 
{ 
 def bestaudio = audio.max{ it.Channels as int }
 bestaudio.Format_AdditionalFeatures + ' ' + bestaudio.language + ' ' 
} { audio.groupBy{ it.Language }.collect{ k, v-> v.size() > 1 ? v.size() + k : k } } {fn.matchAll(/UHD|4K|MVC|framepacked/)} {s3d} {subt}
Unfortunately, I am still getting the error:

Code: Select all

Illegal Argument: java.nio.file.NoSuchFileException: /usr/syno/synoman/webapi/{  ({ )
Illegal Argument: java.nio.file.NoSuchFileException: /usr/syno/synoman/webapi/ def bestaudio = audio.max{ it.Channels as int } ( def bestaudio = audio.max{ it.Channels as int })
Illegal Argument: java.nio.file.NoSuchFileException: /usr/syno/synoman/webapi/ bestaudio.Format_AdditionalFeatures + ' ' + bestaudio.language + ' '  ( bestaudio.Format_AdditionalFeatures + ' ' + bestaudio.language + ' ' )
Illegal Argument: java.nio.file.NoSuchFileException: /usr/syno/synoman/webapi/} { audio.groupBy{ it.Language }.collect{ k, v-> v.size() > 1 ? v.size() + k : k } } {fn.matchAll(/UHD|4K|MVC|framepacked/)} {s3d} {subt} (} { audio.groupBy{ it.Language }.collect{ k, v-> v.size() > 1 ? v.size() + k : k } } {fn.matchAll(/UHD|4K|MVC|framepacked/)} {s3d} {subt})
Illegal Argument: java.nio.file.NoSuchFileException: /usr/syno/synoman/webapi/skipExtract=y (skipExtract=y)
Illegal Argument: java.nio.file.NoSuchFileException: /usr/syno/synoman/webapi/subtitles=ger (subtitles=ger)
Illegal Argument: java.nio.file.NoSuchFileException: /usr/syno/synoman/webapi/excludeList=.excludes (excludeList=.excludes)
Argument[1]: File does not exist: { 
Argument[2]: File does not exist:  def bestaudio = audio.max{ it.Channels as int }
Argument[3]: File does not exist:  bestaudio.Format_AdditionalFeatures + ' ' + bestaudio.language + ' ' 
Argument[4]: File does not exist: } { audio.groupBy{ it.Language }.collect{ k, v-> v.size() > 1 ? v.size() + k : k } } {fn.matchAll(/UHD|4K|MVC|framepacked/)} {s3d} {subt}
Argument[5]: File does not exist: skipExtract=y
Argument[6]: File does not exist: subtitles=ger
Argument[7]: File does not exist: excludeList=.excludes
When I test the same statement with the desktop application I get:

A/Avatar Collection/Avatar (2009)/Avatar (2009) BluRay HEVC 2160p HDR 16-ch en [de, en] [UHD, 4K]

My .sh-script looks like this now:

Code: Select all

/volume1/@appstore/filebot/filebot.sh -script 'fn:amc' --action 'test' '/volume1/data' --output /volume1/03_Filme -non-strict --conflict auto --lang en --def '@/volume1/03_Filme/Sorting Scripts/filebotargs.txt' 'skipExtract=y' 'subtitles=ger'  'excludeList=.excludes' --log info --log-file '/volume1/03_Filme/Filebotlogs/filebot.log' 

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

Re: Some questions regarding renaming

Post by rednoah » 01 Mar 2020, 18:19

1. Open the FileBot Format Editor GUI and copy & paste your format.
2. Create a new text file MovieFormat.groovy and paste your format.
3. Use --def [email protected]/path/to/MovieFormat.groovy in your filebot call

:idea: --def [email protected] syntax allows you to read a single script parameter from a text file.




:!: You are using @args syntax for arguments and not binding value, where arguments are read from a text file line by line:

Code: Select all

movieFormat=/volume1/03_Filme/01 Movies/{az}/{collection}/{any{localize[languages[0]].n} {n}.upperInitial() } ({y})/{any{localize[languages[0]].ny {ny}.upperInitial() } {tags} {source} {vc} {vf} { any{hdr}{'SDR'} }
The --def name=value sequence ends here. The rest is interpreted as input arguments, which is self-evident in the numerous console errors:

Code: Select all

{ 

Code: Select all

 def bestaudio = audio.max{ it.Channels as int }

Code: Select all

 bestaudio.Format_AdditionalFeatures + ' ' + bestaudio.language + ' ' 

Code: Select all

} { audio.groupBy{ it.Language }.collect{ k, v-> v.size() > 1 ? v.size() + k : k } } {fn.matchAll(/UHD|4K|MVC|framepacked/)} {s3d} {subt}
The errors look the same as before when you didn't use '...' correctly because both mistakes lead to random Groovy code being being passed in as input file arguments. If you use ' as separator you can't use ' in the value, if you use newline as separator, you can't use newline in the value, etc. ;)
:idea: Please read the FAQ and How to Request Help.

justkidding
Posts: 38
Joined: 12 Oct 2015, 20:42

Re: Some questions regarding renaming

Post by justkidding » 01 Mar 2020, 19:29

Thank you! The movieformat.groovy file works just fine :).
Is there a list what functions I can call inside the def-expression (instead of .max)?
For example I want to try to find the information of the german audio line with the most channels.
Is this also possible?

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

Re: Some questions regarding renaming

Post by rednoah » 01 Mar 2020, 19:48

Yes, the entire Java/Groovy runtime is at your disposal, but the docs are so complete that you will most likely find them completely useless for your specific use case. :lol:

:arrow: Iterable.max()
:arrow: Iterable.findAll()


:idea: You will probably find a general Groovy beginners tutorial more helpful than the complete technical documentation: https://docs.groovy-lang.org/next/html/ ... tions.html
:idea: Please read the FAQ and How to Request Help.

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

Re: Some questions regarding renaming

Post by kim » 01 Mar 2020, 21:51

justkidding wrote:
01 Mar 2020, 19:29
For example I want to try to find the information of the german audio line with the most channels.
Is this also possible?
I modified my code for you ;)
viewtopic.php?f=5&t=5285&p=48761#p48761

justkidding
Posts: 38
Joined: 12 Oct 2015, 20:42

Re: Some questions regarding renaming

Post by justkidding » 02 Mar 2020, 06:09

@rednoah thanks, this is quite some stuff to understand if you are not familiar with such things :D
@kim Wow, this looks awesome. Thank you so much. I will try as soon as I get home.

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

Re: Some questions regarding renaming

Post by rednoah » 02 Mar 2020, 06:42

Yes, indeed. FileBot is built on a massive general-purpose platform, so you can do absolutely anything, which makes it difficult to come up with a finite list of things that a FileBot users might be interested in.

So it's better to ask "I want to do this, how do I do it?" and then learn by example and get a feel for how things work.
:idea: Please read the FAQ and How to Request Help.

justkidding
Posts: 38
Joined: 12 Oct 2015, 20:42

Re: Some questions regarding renaming

Post by justkidding » 02 Mar 2020, 19:07

@rednoah I absolutely understand that. And the support from you and the other members is outstanding :).
@kim Your coding is really great. The end of my coding looks like this now.

Code: Select all

 	
	def allStreams = audioStreams.collect{ filter(it) }*.minus(null).unique()*.join(' ')
	def preferredStream = oneStream(audioStreams.findAll{ it.index == audioStreams.index.max() })
	def bestBitRate = oneStream(audioStreams.findAll{ it.bitrate == audioStreams.bitrate.max() })
	def defaultStream = oneStream(audioStreams.findAll{it.default == true})
	def bestPreferredGer = any{audioStreams.findAll{it.lang == preferredGer }.sort{it.bitrate <=> it.bitrate}.collect{ filter(it) }*.minus(null).unique().get(0).join(' ')}{null}
	def bestPreferredEng = any{audioStreams.findAll{it.lang == preferredEng }.sort{it.bitrate <=> it.bitrate}.collect{ filter(it) }*.minus(null).unique().get(0).join(' ')}{null}
	
	[bestBitRate, preferredStream, bestPreferredEng, bestPreferredGer ].unique().join(' ').space(' ')

Everything is working great. I have only one small issue. If a file has no german audio line for example it writes the value "null". How can I avoid this? If there is no such line it should just write nothing.
At the moment I get this for example:

Code: Select all

KOR TrueHD ATMOS 7 1 [11 Objs] null DEU DTS-HD MA 5 1

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

Re: Some questions regarding renaming

Post by kim » 02 Mar 2020, 20:11

Was the lang code "Deu" and not "Ger"? you need to change that part

Code: Select all

any{SOMETHING}{null}
Replace

Code: Select all

{null}
with e.g.

Code: Select all

{'nothing'}
= any{if NOT null use this}{use if first fail}

OR I used

Code: Select all

{defaultStream}
btw: edit this if you don't want some of the info

Code: Select all

def filter = { [it.codec, it.ch, it.objects, it.lang] }
EDIT: bug fix

Code: Select all

.sort{it.bitrate}.reverse()
OR

Code: Select all

.sort{a, b -> b.bitrate <=> a.bitrate}

justkidding
Posts: 38
Joined: 12 Oct 2015, 20:42

Re: Some questions regarding renaming

Post by justkidding » 03 Mar 2020, 10:39

kim wrote:
02 Mar 2020, 20:11
Was the lang code "Deu" and not "Ger"? you need to change that part


Yeah, the language code for German is "deu". I already changed it :). Maybe this is dependent on the installation of media info. I don't know.
kim wrote:
02 Mar 2020, 20:11

Code: Select all

any{SOMETHING}{null}
Replace

Code: Select all

{null}
with e.g.

Code: Select all

{'nothing'}
= any{if NOT null use this}{use if first fail}

OR I used

Code: Select all

{defaultStream}

Thank you - that's perfect. I just added {preferred Stream}.
kim wrote:
02 Mar 2020, 20:11
btw: edit this if you don't want some of the info

Code: Select all

def filter = { [it.codec, it.ch, it.objects, it.lang] }

Already did :)
kim wrote:
02 Mar 2020, 20:11
EDIT: bug fix

Code: Select all

.sort{it.bitrate}.reverse()
OR

Code: Select all

.sort{a, b -> b.bitrate <=> a.bitrate}
Thank you I will adapt it.

@rednoah is it possible to use filebot also for renaming jpg or png files?
In my scraped movie folders at the moment I have something like this:

Avatar (2009) Bluray 6ch.mkv
Avatar (2009) Bluray 6ch-fanart.jpg

Now I want to rename my movie files with the new script. Is it possible to rename the jpg-files with the same name but keeping the part which is behind the -? So an optimal result would be for example

Avatar (2009) Bluray 1080p HDR DEU Atmos.mkv
Avatar (2009) Bluray 1080p HDR DEU Atmos-fanart.jpg

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

Re: Some questions regarding renaming

Post by rednoah » 03 Mar 2020, 11:10

Yes, companion files (with the same name) are matched to the same movie object automatically and so things should work as expected out of the box.


:idea: Note that the amc script explicitly ignores non-video files. So while the answer above generally applies to GUI and CLI usage, it does not for the amc script specifically.
:idea: Please read the FAQ and How to Request Help.

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

Re: Some questions regarding renaming

Post by kim » 03 Mar 2020, 15:22

you can use something like this:

Code: Select all

{ext = 'jpg' ? '-' + fn.match(/fanart|otherword/) : ''}

justkidding
Posts: 38
Joined: 12 Oct 2015, 20:42

Re: Some questions regarding renaming

Post by justkidding » 03 Mar 2020, 17:10

@rednoah in the gui without doing anything I loose the "-fanart"
8 Mile (2002) 1080P X264 AAC Tt0298203-fanart.jpg
becomes to
8 Mile (2002) x264 1080p SDR.jpg

@Kim
I've included your bug fix (hope it's correct)

Code: Select all

 	def bestPreferredGer = any{audioStreams.findAll{it.lang == preferredGer }.sort{a, b -> b.bitrate <=> a.bitrate}.collect{ filter(it) }*.minus(null).unique().get(0).join(' ')}{defaultStream} 
Your statement for the .jpg-files is working quite good.
I just have the problem that it adds a space before the "-".
As a result I get
8 Mile (2002) x264 1080p SDR -fanart.jpg
How can I change it to
8 Mile (2002) x264 1080p SDR-fanart.jpg
?
I think it's because for at least one part expression it doesn't find a value.
Because if I do something like

Code: Select all

 {ny.upperInitial()} {tags}{fn.match(/-fanart|-banner|-clearart|-clearlogo|-discart|-landscape|-poster/)} 
it adds a space before the "-fanart".

Also I have a problem with one of my video files in finding the audio languages using your script. It's a .mp4-file if that matters.
MediaInfo gives me the following information for the audio line:

Code: Select all

Format	AAC
Format/String	AAC LC
Format/Info	Advanced Audio Codec Low Complexity
Format_Commercial	AAC
Format_Settings_SBR	No (Explicit)
Format_Settings_SBR/String	No (Explicit)
Format_AdditionalFeatures	LC
CodecID	mp4a-40-2
Duration	6627775
Duration/String	1 h 50 min
Duration/String1	1 h 50 min 27 s 775 ms
Duration/String2	1 h 50 min
Duration/String3	01:50:27.775
Duration/String4	01:50:10:07
Duration/String5	01:50:27.775 (01:50:10:07)
BitRate_Mode	VBR
BitRate_Mode/String	Variable
BitRate	325576
BitRate/String	326 kb/s
BitRate_Maximum	338312
BitRate_Maximum/String	338 kb/s
Channel(s)	6
Channel(s)/String	6 channels
ChannelPositions	Front: L C R, Side: L R, LFE
ChannelPositions/String2	3/2/0.1
ChannelLayout	C L R Ls Rs LFE
SamplesPerFrame	1024
SamplingRate	48000
SamplingRate/String	48.0 kHz
FrameRate	46.875
FrameRate/String	46.875 FPS (1024 SPF)
Compression_Mode	Lossy
Compression_Mode/String	Lossy
StreamSize	269732358
StreamSize/String	257 MiB (9%)
StreamSize/String1	257 MiB
StreamSize/String2	257 MiB
StreamSize/String3	257 MiB
StreamSize/String4	257.2 MiB
StreamSize/String5	257 MiB (9%)
StreamSize_Proportion	0.09182
Language	en
Language/String	English
Language/String1	English
Language/String2	en
Language/String3	eng
Language/String4	en
Encoded_Date	UTC 2014-10-12 23:50:05
Tagged_Date	UTC 2014-10-13 22:41:53
Do you see where the issue could be?
Last edited by justkidding on 03 Mar 2020, 18:45, edited 2 times in total.

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

Re: Some questions regarding renaming

Post by rednoah » 03 Mar 2020, 17:26

justkidding wrote:
03 Mar 2020, 17:10
@rednoah in the gui without doing anything I loose the "-fanart"
8 Mile (2002) 1080P X264 AAC Tt0298203-fanart.jpg
becomes to
8 Mile (2002) x264 1080p SDR.jpg
Yes, it'll work exactly the same as for the corresponding video file. If you want to carry over specific patterns from the original file, then you can do that via your custom format, as always, same as for video files. ;)

e.g.

Code: Select all

{fn.match(/-fanart/)}
:idea: This will add -fanart if {fn} contains -fanart, which presumably applies only to your artwork files.


You can of course expand on this as suggested by @kim in his post above:
kim wrote:
03 Mar 2020, 15:22
you can use something like this:

Code: Select all

{ext = 'jpg' ? '-' + fn.match(/fanart|otherword/) : ''}
:idea: Please read the FAQ and How to Request Help.

justkidding
Posts: 38
Joined: 12 Oct 2015, 20:42

Re: Some questions regarding renaming

Post by justkidding » 03 Mar 2020, 18:08

Now I get it :).
When using the GUI is there a way to change the minimum duration for video files?
I know for scripts there is --def minLengthMS=0 but I don't find any option is the windows app?

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

Re: Some questions regarding renaming

Post by kim » 03 Mar 2020, 21:10

" problem that it adds a space before the "-". "

do you use this ?

Code: Select all

/data/Movies/{az}/{collection}/{ny.UpperInitial()}/{n.upperInitial()} ({y})/{n.upperInitial()} ({y}) {fn.matchAll(/UHD|4K|MVC|framepacked|FSBS|HSBS|HOU|FOU/)} {source} {special} {tags} {vf} {vc} {hdr} {s3d} {aco} {channels} {audioLanguages} {subt}
the problem is the spaces between {}'s "{a} {b} {c}"
fix = {' '+a}... now only a space if a is not empty

so like this:

Code: Select all

/data/Movies/{az}{'/'+collection}{'/'+ny.upperInitial()}{'/'+n.upperInitial()}{' ('+y+')'}/{n.upperInitial()}{' ('+y+')'}{' '+fn.matchAll(/UHD|4K|MVC|framepacked|FSBS|HSBS|HOU|FOU/)}{' '+source}{' '+special}{' '+tags}{' '+vf}{' '+vc}{' '+hdr}{' '+s3d}{' '+aco}{' '+channels}{' '+audioLanguages}{' '+subt}

Code: Select all

{ext = 'jpg' ? fn.match(/((?:-)(?:fanart|banner|clearart|clearlogo|discart|landscape|poster)$)/) : ''}
"Also I have a problem with one of my video files in finding the audio languages using your script"
I dont see a problem
try only my format in the GUI... what is output ?
viewtopic.php?f=5&t=5285&p=48761#p48761

justkidding
Posts: 38
Joined: 12 Oct 2015, 20:42

Re: Some questions regarding renaming

Post by justkidding » 03 Mar 2020, 21:38

kim wrote:
03 Mar 2020, 21:10
" problem that it adds a space before the "-". "

do you use this ?

Code: Select all

/data/Movies/{az}/{collection}/{ny.UpperInitial()}/{n.upperInitial()} ({y})/{n.upperInitial()} ({y}) {fn.matchAll(/UHD|4K|MVC|framepacked|FSBS|HSBS|HOU|FOU/)} {source} {special} {tags} {vf} {vc} {hdr} {s3d} {aco} {channels} {audioLanguages} {subt}
the problem is the spaces between {}'s "{a} {b} {c}"
fix = {' '+a}... now only a space if a is not empty

so like this:

Code: Select all

/data/Movies/{az}{'/'+collection}{'/'+ny.upperInitial()}{'/'+n.upperInitial()}{' ('+y+')'}/{n.upperInitial()}{' ('+y+')'}{' '+fn.matchAll(/UHD|4K|MVC|framepacked|FSBS|HSBS|HOU|FOU/)}{' '+source}{' '+special}{' '+tags}{' '+vf}{' '+vc}{' '+hdr}{' '+s3d}{' '+aco}{' '+channels}{' '+audioLanguages}{' '+subt}
Awesome, thank you!
kim wrote:
03 Mar 2020, 21:10
"Also I have a problem with one of my video files in finding the audio languages using your script"
I dont see a problem
try only my format in the GUI... what is output ?
viewtopic.php?f=5&t=5285&p=48761#p48761
I get this:
[Expression yields empty value: Binding "default": undefined] 8 Mile (2002)
I found some other files were I have the same problem. For these I get the same message.

For one file, which is an .iso I get following error:
[Expression yields empty value: Binding "audio": java.lang.NullPointerException] The BFG (2016)

Post Reply