File Relations: Link Expression Problem

Started by okiedokie, May 06, 2018, 11:50:16 PM

Previous topic - Next topic

okiedokie

I can't figure out how to adjust the Link Expression to work with my naming scheme, if it's even possible.  Will someone take a look and see if they have any suggestions, please?

Master Expression:  \.(arw)$

Replacement Expression:  ^_*//

Link Expression:  ^(_*{name})[+\-_]*[0-9|a-z]*\.(jpg|jpeg|dng|tif)$

Most of my images are a blend of three or more images.  I'd like to name the blended image in such a way to be able to identify all the images invloved,e.g.
Three master files:  cre_180415_000850, cre_180415_000851, cre_180415_000852
Final version:  cre_180415_00850_51_52
At the moment it works for:  cre_180415_000850_51
It doesn't work for:  cre_180415_000850_51_  Or anything added after the final _
I can't figure out what I need to do.
Thank you!


Mario

This is quite a unusual way to name files.

The problem is that you are not just appending something to your file name, you are changing it completely.
This means that the name of the original file is not longer part of your derived file names:

For example:

1. cre_180415_000850
2. cre_180415_000851

But Name 2 does not contain name 1 anymore. Since your regular expression includes the original via the {name} token, it will not match.
Matching derived file names which append text to the original file name in some way is easy to do. Your special naming schema is not.

For your schema you would need a feature which uses only a part of the original file name. Judging by your example, this would probably be cre_180415_ followed by any number of characters. Unfortunately, there is no easy way to do this with a regular expression (at least none I know of). IMatch has no token which allows you to represent only part of the file name in the regular expression.It offers {name}, {ext} and {filename} but no tokens for extracting parts of the original name.

Googling for "match the first n characters with a regular expression" did not yield anything.

I recommend rethinking your file naming schema if possible.

One way to handle this (not actually tried) would maybe be

1. Matching all \.arw files with all \.jpg files.
2. Enabling the "Limit by Variables" function with regular expression
3. Then setting up a master expression which matches the master and a version expression which uses something like {File.Name|substr:0,11}.*\.jpg to extract the first 11 characters of the master file name, following by anything and ending in \.jpg.

Complicated, will need some experiments on your side. And it will probably be slow, too.

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

Carlo Didier

I had a similar problem with the naming of my stitched/HDR/Pano files and I had that solved by a script (which was triggered automatically in the old iMatch5).
Currently I try to make it work in a new javascript app. That might also be a solution for you if it's ok to select the files and then run the app.
My scheme is this: D20180117102-111 would designate a composite image made from images named D20180117102, D20180117103, D20180117104, ..., D20180117111
You can see that this would not be treatable by either a simple relation or a regular expression, although it's very simple and clear for a human.

sinus

Quote from: okiedokie on May 06, 2018, 11:50:16 PM
I can't figure out how to adjust the Link Expression to work with my naming scheme, if it's even possible.  Will someone take a look and see if they have any suggestions, please?

Master Expression:  \.(arw)$

Replacement Expression:  ^_*//

Link Expression:  ^(_*{name})[+\-_]*[0-9|a-z]*\.(jpg|jpeg|dng|tif)$

Most of my images are a blend of three or more images.  I'd like to name the blended image in such a way to be able to identify all the images invloved,e.g.
Three master files:  cre_180415_000850, cre_180415_000851, cre_180415_000852
Final version:  cre_180415_00850_51_52
At the moment it works for:  cre_180415_000850_51
It doesn't work for:  cre_180415_000850_51_  Or anything added after the final _
I can't figure out what I need to do.
Thank you!

Try to take the length (in this case 10) of your link-expression, like
^{name}:10.*\.(jpg|jpeg|dng|tif)$

should work, because it counts simply the first letters/numbers.
Maybe I am wrong, but at least it works for me.  8)
Best wishes from Switzerland! :-)
Markus

okiedokie

Mario, thank you for you explanation.  You made it simple enough I understand why my naming scheme won't work.  I'll change my perspective.  Thank you.

okiedokie

Thank you, Carlo.  I, too, had a script in the old IMatch that worked for me.  That's an indication of how long I've been toying with this particular problem.  I appreciate your comment.

okiedokie

Hi Sinus.  Thank you for your suggestion.  I tested it and it matched.  I'll put it through a few more paces, though.  Thanks again.

[/quote]
Try to take the length (in this case 10) of your link-expression, like
^{name}:10.*\.(jpg|jpeg|dng|tif)$

sinus

Quote from: okiedokie on May 07, 2018, 01:04:54 PM
Hi Sinus.  Thank you for your suggestion.  I tested it and it matched.  I'll put it through a few more paces, though.  Thanks again.

Quote
Try to take the length (in this case 10) of your link-expression, like
^{name}:10.*\.(jpg|jpeg|dng|tif)$

Cool, if it would work for you.
Finally this should really work.
Best wishes from Switzerland! :-)
Markus

Mario

Do you have any reference about the :nn (:10) part? I don't recall seeing this anywhere...but I'm no regexp expert. I usually manage with very simple rules.. :D
If this works and is covered in a doc I will mention it in the IMatch help so the next user with the same problem finds a solution more quickly.
-- Mario
IMatch Developer
Forum Administrator
http://www.photools.com  -  Contact & Support - Follow me on 𝕏 - Like photools.com on Facebook

sinus

Quote from: Mario on May 07, 2018, 01:35:35 PM
Do you have any reference about the :nn (:10) part? I don't recall seeing this anywhere...but I'm no regexp expert. I usually manage with very simple rules.. :D
If this works and is covered in a doc I will mention it in the IMatch help so the next user with the same problem finds a solution more quickly.

You speak from me, I guess?
Well, I am pretty sure, that you have added this in an update, quite long ago. I am prettey sure, really.  ;D
I can not remember, when, but I am really very sure, that you have added this once.
Then some users had some examples uploaded, and because this was very easy and simple for me, I adapted it and since then I use it.

Is it not this, like in the help, see my attachement?

Or do you speak from something else? (sorry, I am bit in a hurry, that is why I am not that exactly in writing)
Best wishes from Switzerland! :-)
Markus

Mario

Geez
IMatch is sooo big and has so many features, I cannot keep everything in my head anymore or remember everything. I should rely on the IMatch help...

On the https://www.photools.com/help/imatch/#rel_config.htm page, under the headline Using only a part of the Master file name it is already documented and explained.
-- Mario
IMatch Developer
Forum Administrator
http://www.photools.com  -  Contact & Support - Follow me on 𝕏 - Like photools.com on Facebook

sinus

Quote from: Mario on May 07, 2018, 03:17:11 PM
Geez
IMatch is sooo big and has so many features, I cannot keep everything in my head anymore or remember everything. I should rely on the IMatch help...

On the https://www.photools.com/help/imatch/#rel_config.htm page, under the headline Using only a part of the Master file name it is already documented and explained.

;D 8) :D ;D 8)

Well, IMatch IS REALLY big and HAS so many features.  :D
Best wishes from Switzerland! :-)
Markus