Compare two variables

Started by ben, March 24, 2019, 01:27:14 PM

Previous topic - Next topic

ben

Hello everyone,

is there any way of comparing two different variables and mark the files that are identical?
Maybe the filter panel or data driven categories or something else?

I would like to find all files where {File.DateTime} and {File.Modified} are identical.

Thanks and have a nice sunday afternoon.
Ben

Mario

Hm.

This variable returns E when the DateTime and Modified are Equal, else D

{File.DateTime|strcomp:{File.Modified},D,E,D}

You can use this to create a data-driven category. All files will end up either in the E or D child category.
-- Mario
IMatch Developer
Forum Administrator
http://www.photools.com  -  Contact & Support - Follow me on 𝕏 - Like photools.com on Facebook

ben

Cool, thanks a lot.
Works as it should. Amazing

sinus

Quote from: ben on March 24, 2019, 10:23:58 PM
Cool, thanks a lot.
Works as it should. Amazing

Yes, Variables are cool!  ;D

BTW, ben, do not forget look at the (new since some versions) math-possibilities from variables.
(in the help under: math: Op, Value {,Decimals})
(simply to know, that some basic-maths are possible)
Best wishes from Switzerland! :-)
Markus

Mario

Using variables as the source for data-driven categories can be slow, but at the same time allows to solve many tricky problems.
Another variable expression for this case would be using datecomp:

{File.DateTime|format:YYYY-MM-DD hh:mm:ss;datecomp:eq,{File.Modified|format:YYYY-MM-DD hh:mm:ss},T,F}

This expression compares date and time and returns T if they are identical, else F.
If you are only interested in the date part (ignoring time), you could also use:

{File.DateTime|format:YYYY-MM-DD;datecomp:eq,{File.Modified|format:YYYY-MM-DD},T,F}
-- Mario
IMatch Developer
Forum Administrator
http://www.photools.com  -  Contact & Support - Follow me on 𝕏 - Like photools.com on Facebook

ben

Very interesting, thanks.
I sometimes use variables and they already helped me quite a few time in the past.
Most of the time I get stuck when trying to connect several variable  expressions.
Like the one in Mario's second post.
I wouldn't know which rules to follow. I know there is a section in the help covering this in a general way, but that didn't help me

Mario

It's really simple. You can use a variable almost everywhere you can use a literal value (inside the {} of the outer/starting variable.
The VarToy is a great app to play with variables and try things out.
-- Mario
IMatch Developer
Forum Administrator
http://www.photools.com  -  Contact & Support - Follow me on 𝕏 - Like photools.com on Facebook