How do I tag 10bit files?

All about user-defined episode / movie / file name format expressions
Post Reply
chase29
Posts: 4
Joined: 18 Sep 2021, 10:46

How do I tag 10bit files?

Post by chase29 »

Hi,

I have the following problem with integers in the format expressions and replacing them with normal regex.
I was told that for all integers object.toString is implemented by default, as I was asking if I could use the supplied string methods.

But I do not get the following to work :
If bitdepth = 10 replace it with 10bit. all my other regexes I use on strings work, I tried everything here from '10' to /10/ etc., I simply get no replacement for it, it is just cut out of the filename at all, if I use it without the replace it just prints 10 in the filename (as expected :D)

How has this to be done for integers here?

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

Re: Problem with integers in format expression

Post by rednoah »

Presumably, you mean to tag 10bit files:
* add 10bit for 10bit files
* don't add anything for non-10bit files


e.g. check if bitdepth is 10

Code: Select all

{ bitdepth == 10 ? ' [10bit]' : '' }

e.g. you can do the same check with the ==~ regex match operator but that just adds unnecessary complexity in this case:

Code: Select all

{ bitdepth ==~ /10/ ? ' [10bit]' : '' }


EDIT:

:idea: As for using String methods on non-String objects, here's how that'd work:

Code: Select all

{ bitdepth.toString().concat('bit') }
:idea: Please read the FAQ and How to Request Help.
chase29
Posts: 4
Joined: 18 Sep 2021, 10:46

Re: How do I tag 10bit files?

Post by chase29 »

Argh, I sat way too long in front of the PC already, I simply misplaced the toString method.
Because I need a replace, if not 10bit I don't want it at all.

Works like a charm, and of course your first solution is most elegant and easy LOL

Thanks!
sselemit
Posts: 8
Joined: 28 Sep 2021, 09:55

Re: How do I tag 10bit files?

Post by sselemit »

It does not work if my code is like this

Code: Select all

{ '  '+bitdepth == 10 ? '10bit' : null }
Does work in this case

Code: Select all

{ bitdepth == 10 ? '10bit' : null }
I'm not sure what was wrong.
User avatar
rednoah
The Source
Posts: 22923
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: How do I tag 10bit files?

Post by rednoah »

e.g.

Code: Select all

{ bitdepth == 10 ? ' 10bit' : null }

:idea: Note that equals doesn't work between String / Integer types, i.e. Integer 10 == 10 and String "10" == "10" is true, but "10" == 10 is not.
:idea: Please read the FAQ and How to Request Help.
sselemit
Posts: 8
Joined: 28 Sep 2021, 09:55

Re: How do I tag 10bit files?

Post by sselemit »

I'm just wondering why can't I add

Code: Select all

' '+
in front of the {bitdepth} binding as this works for other bindings.
If I remove that, the binding works normally.
I want filebot to add a space in case of null.
kim
Power User
Posts: 1251
Joined: 15 May 2014, 16:17

Re: How do I tag 10bit files?

Post by kim »

' ' + 10 same as ' 10'
'10' (String) == 10 (Integer) = not the same

try this:

Code: Select all

{' '+ (bitdepth == 10 ? '10bit' : '')}
User avatar
rednoah
The Source
Posts: 22923
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: How do I tag 10bit files?

Post by rednoah »

sselemit wrote: 26 Dec 2021, 20:19 I want filebot to add a space in case of null.
e.g.

Code: Select all

{ bitdepth == 10 ? ' 10bit' : ' ' }

:idea: Note that FileBot will replace \s+ (any sequence of space-like characters) with a single standard space character regardless of custom format. So if you want multiple spaces in a row in your custom file names, then you're probably out of luck on that particular front.
:idea: Please read the FAQ and How to Request Help.
Post Reply