Page 1 of 1

How do I tag 10bit files?

Posted: 18 Sep 2021, 16:18
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

Re: Problem with integers in format expression

Posted: 18 Sep 2021, 16:24
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') }

Re: How do I tag 10bit files?

Posted: 18 Sep 2021, 17:31
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!

Re: How do I tag 10bit files?

Posted: 26 Dec 2021, 10:07
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.

Re: How do I tag 10bit files?

Posted: 26 Dec 2021, 11:23
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.

Re: How do I tag 10bit files?

Posted: 26 Dec 2021, 20:19
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.

Re: How do I tag 10bit files?

Posted: 27 Dec 2021, 00:24
by kim
' ' + 10 same as ' 10'
'10' (String) == 10 (Integer) = not the same

try this:

Code: Select all

{' '+ (bitdepth == 10 ? '10bit' : '')}

Re: How do I tag 10bit files?

Posted: 27 Dec 2021, 02:46
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.