Category formula based on filename range

Started by Carlo Didier, October 28, 2023, 11:51:59 PM

Previous topic - Next topic

Carlo Didier

Has anyone a non-regexp formula like (filename > "XXX") AND (filename < "YYY")
Sounds simple, but I can't find the filename in any metadata tag and I don't know how to specify the ">" and "<" operators.
Example: A category including all files with names > "D20230727000*" and < "D20230821999".
Currently I'm doing that semi manually with one script creating a category with a specified file name range in it's description field and a second script which finds and assigns all matching files to those categories. All run manually, so, cumbersome and prone to forgetting to update ...

Mario

#1
The file.name standard tag contains the file name.
strcomp allows you compare two strings. If this works depends of course on the format of your file names. Easy to test in VarToy.
substr allows you to extract parts of a variable value.
Casting Variables allows you to force-convert text into numbers
numcomp:Op,Value,TV,FV,Mode]numcomp[/url] allows you to compare two numbers.
The computationally @Variable[] allows you to produce category formulas based on variables.
The rest depends on what your actual requirements are.
-- Mario
IMatch Developer
Forum Administrator
http://www.photools.com  -  Contact & Support - Follow me on 𝕏 - Like photools.com on Facebook

Carlo Didier

Ok. So shouldn't this return true instead of 20230727006?



The extraction of the filename part I want does work:


I also tried to add a cast, but the result is the same:

Darius1968

About the information given in the IMatch help, under @Variable, for...
... @Variable[{File.Persons.Label},contains-any,Tom;Susan]

Are there any typos for that statement?  I ask because the help doesn't document anything about the text any, where the formatting function contains: is concerned. 



Mario

-- Mario
IMatch Developer
Forum Administrator
http://www.photools.com  -  Contact & Support - Follow me on 𝕏 - Like photools.com on Facebook

Carlo Didier

Quote from: Carlo Didier on November 01, 2023, 11:29:22 PMOk. So shouldn't this return true instead of 20230727006?

The extraction of the filename part I want does work:

I also tried to add a cast, but the result is the same:
Hmm, why have my screenshots disappeared from the post?

I have attached a new one to show the issue. Apart from the first two lines, all others should return either true or false.iMatch variables.png

axel.hennig

Only use "|" after "File.Name". Afterwards ";" instead of "|".

sinus

#7
Quote from: axel.hennig on November 03, 2023, 07:54:03 AMOnly use "|" after "File.Name". Afterwards ";" instead of "|".

Yep, without tried it, I think, Axel is correct.

Normally first use a | and the second should be a ;  means:

{File.Name|substr:1,11;cast:int;between ....

hmmm, btw, just checked one of my variable, what works great:
{File.Name|substr:2,11;replace:-==999999;between:1,450,ANTIKE - EISENZEIT,;between:451,2200,ANTIKE - BRONZEZEIT,;between:2201,5500,STEINZEIT – JUNGSTEINZEIT - NEOLITHIKUM,;between:5501,9700,STEINZEIT – MITTELSTEINZEIT - MESOLITHIKUM,;between:9701,43000,STEINZEIT - ALTSTEINZEIT - JUNGPALÄOLITHIKUM;between:43001,300000,STEINZEIT – ALTSTEINZEIT - MITTELPALÄOLITHIKUM,;between:300001,1000000,STEINZEIT – ALTSTEINZEIT - ALTPALÄOLITHIKUM,;between:1000001,1800000,ERDNEUZEIT,;between:1800001,65000000,ERDMITTELALTER - TERTIÄR,;between:65000001,144000000,ERDMITTELALTER - KREIDE,;between:144000001,206000000,ERDMITTELALTER - JURA,;between:206000001,248000000,ERDMITTELALTER - TRIAS,;between:248000001,290000000,ERDALTERTUM - PERM,;between:290000001,354000000,ERDALTERTUM - KARBON,;between:354000001,417000000,ERDALTERTUM - DEVON,;between:417000001,4520000000,ERDE IST GEFORMT;between:4520000001,14000000000,UNIVERSUM WIRD GESCHAFFEN,}


Best wishes from Switzerland! :-)
Markus

thrinn

You have a typo here: It is numcomp, not numomp.
But the main thing is: You can not have multiple pipe symbols (|) in one expression. Try the following expression:

3: {File.Name|substr:1,11;between:20230727001,20230727999,tv,fv}
This seems to work even without a cast to int.
Thorsten
Win 10 / 64, IMatch 2018, IMA

Carlo Didier

Thorsten, das wars! Vielen Dank and Dich und Markus!
Das mit nur einem pipe war mir nicht bewusst. Der Tippfehler kam übrigens erst beim erneuten eintippen um einen neuen Screenshot zu machen. Auch richtig geschrieben hats nicht funktioniert wegen der multiplen pipes.
Ist das irgendwo im Help klar angegeben? Ist mir jedenfalls nicht aufgefallen.

Sorry, forgot the English speakers here, so here's the translation:

You were right, Thorsten! Many thanks to you and Markus!
I wasn't aware of the limitation to one pipe in an expression. The typo only came when I retyped the expressions to make a new screenshot. Even correctly written, it didn't work, because of the multiple pipes.
Is that limitation clearly stated in the Help? I sure didn't notice it.

Mario

-- Mario
IMatch Developer
Forum Administrator
http://www.photools.com  -  Contact & Support - Follow me on 𝕏 - Like photools.com on Facebook