Custom File Masks when assigning Stack Markers

marklevine
Posts: 55
Joined: 26 Dec 21 23:07

Custom File Masks when assigning Stack Markers

Post by marklevine »

I have been struggling with Custom File Masks for years and I'd really love to get some help from the community. My first post on this topic is from Dec-2021 and I complain that I had already worked on it for months. So that makes at least two years when I've tried to find Custom File Masks that work for me! My first post got no replies. Back then, I was struggling with custom file masks to assign the top item of a version set. Since then under the advice of Hert, I've migrated my catalog to use stacks. Each stack contains a single image with its derived files.

Here is an example using the actual name of a file I'm currently struggling with:

20231006-DSCF3841.RAF <- the original raw
20231006-DSCF3841.JPG <- the original JPG sidecar
20231006-DSCF3841-edited.jpg <-exported from Photolab
20231006-DSCF3841-edited-1.jpg <-exported from Photolab
20231006-DSCF3841-edited-2.jpg <-exported from Photolab

I would like this stack to have three stack markers: Raw, Edited, JPG sidecar. The problem is that two files are being assigned BOTH "Edited" *and* "JPG sidecar". Those files are 20231006-DSCF3841-edited-1.jpg and 20231006-DSCF3841-edited-2.jpg

Can anyone suggest a Custom File Mask that would catch the actual JPG sidecar, named 20231006-DSCF3841.jpg, without also catching the two edited files?

I've suggested to Hert that the custom file masks in Versioning and Stacking ought to accept regular expressions but I don't *think* it does. I suppose I could adjust my workflow to avoid this issue but I would prefer to get the software working to my expectation.

Thanks if you can help.
Hert
Posts: 7871
Joined: 13 Sep 03 6:24

Re: Custom File Masks when assigning Stack Markers

Post by Hert »

Best to also share your current matching rules for the different stack markers. Also, which file you would expect to receive which stack marker in the end situation. That would help the readers here to better understand your problem.

For instance, if you use %FileName.jpg as your rule for JPG Sidecar matching then keep in mind that the edited files also match that rule and so will also receive the JPG Sidecar marker. You want *only* the JPG file without "edited" in its file name to receive the JPG sidecar marker and so your mask should exclude the files that contain "edited" in it.

Without listing your current matching rules, that is just guessing.
This is a user-to-user forum. If you have suggestions, requests or need support then please send a message
BertiIrmo
Posts: 31
Joined: 21 Nov 07 12:59
Location: Hannover, Germany

Re: Custom File Masks when assigning Stack Markers

Post by BertiIrmo »

Hello,
I work with versions and not stacks, but I would rename the photos first:

20231006-DSCF3841.RAF <- name remains
20231006-DSCF3841.JPG <- 20231006-DSCF3841-sidecar.jpg
20231006-DSCF3841-edited.jpg <-20231006-DSCF3841.jpg
20231006-DSCF3841-edited-1.jpg <-20231006-DSCF3841-1.jpg
20231006-DSCF3841-edited-2.jpg <-20231006-DSCF3841-2.jpg

I myself don't use the separate saving and displaying of a sidecar-file, because I have set PSU to display the RAW file in the original state.
For me, every jpg is always edited and special jpgs should be specially named in my opinion.
I have not considered the answer of Hert, he was faster than me.
marklevine
Posts: 55
Joined: 26 Dec 21 23:07

Re: Custom File Masks when assigning Stack Markers

Post by marklevine »

Hert wrote: 23 Oct 23 7:42 Best to also share your current matching rules for the different stack markers. Also, which file you would expect to receive which stack marker in the end situation. That would help the readers here to better understand your problem.

For instance, if you use %FileName.jpg as your rule for JPG Sidecar matching then keep in mind that the edited files also match that rule and so will also receive the JPG Sidecar marker. You want *only* the JPG file without "edited" in its file name to receive the JPG sidecar marker and so your mask should exclude the files that contain "edited" in it.

Without listing your current matching rules, that is just guessing.
I omitted my matching rules because they don't work. Nonetheless, here they are:

"Edited" Custom File Mask: *-edited.jpg,*-edited-1.jpg,*-edited-2.jpg,*-edited-3.jpg
Note: this only works for the first 4 edited versions but I rarely go behind that. The suffixes for 2nd through final edits are added by PhotoLab. I don't believe that it is configurable. If it were, then I would name the second edit "filename-01-edited.jpg" and change my custom mask to require "-edited.jpg" at the end of the name. I have tried using a mask "**edited*.jpg" but I never got good results, so I moved on. Perhaps "*edited*.jpg" could work.

"Email" Custom file mask: *-email.jpg,*-email-1.jpg,*-email-2.jpg,*-email-3.jpg
Note: comments above for "Edited" apply here.

"Instagram" Custom file mask: *-instagram.jpg,*-instagram-1.jpg,*-instagram-2.jpg,*-instagram-3.jpg
Note: comments above for "Edited" apply here.

"Print" Custom File Mask: *-print.jpg

"Tiff" Custom File Mask: *.tif,*.tiff

"JPG sidecar" Custom File Mask: %FileName.JPG
Note: I know this is wrong and needs to be corrected.

"Raw" First RAW found
marklevine
Posts: 55
Joined: 26 Dec 21 23:07

Re: Custom File Masks when assigning Stack Markers

Post by marklevine »

BertiIrmo wrote: 23 Oct 23 7:45 Hello,
I work with versions and not stacks, but I would rename the photos first:

20231006-DSCF3841.RAF <- name remains
20231006-DSCF3841.JPG <- 20231006-DSCF3841-sidecar.jpg
20231006-DSCF3841-edited.jpg <-20231006-DSCF3841.jpg
20231006-DSCF3841-edited-1.jpg <-20231006-DSCF3841-1.jpg
20231006-DSCF3841-edited-2.jpg <-20231006-DSCF3841-2.jpg

I myself don't use the separate saving and displaying of a sidecar-file, because I have set PSU to display the RAW file in the original state.
For me, every jpg is always edited and special jpgs should be specially named in my opinion.
I have not considered the answer of Hert, he was faster than me.
Thanks for your consideration! I am trying to avoid renaming files. If I renamed files, I'd have no problem.
Hert
Posts: 7871
Joined: 13 Sep 03 6:24

Re: Custom File Masks when assigning Stack Markers

Post by Hert »

marklevine wrote: 23 Oct 23 18:41"JPG sidecar" Custom File Mask: %FileName.JPG
Note: I know this is wrong and needs to be corrected.
Try this as your JPG Sidecar marker's custom file mask

Code: Select all

%code 
  if ImageItem.IsJpeg then
    result := ImageItem.FileNameOnly + iif(WideTextPos('-edited', WideLowerCase(ImageItem.FileNameOnly)) > 0, NewGUID, '')
  else
    result := NewGUID;
%/code
If that works then that also holds the clue on how to do the mask for the Edited marker (which is the opposite...> 0 becomes = 0)...
This is a user-to-user forum. If you have suggestions, requests or need support then please send a message
marklevine
Posts: 55
Joined: 26 Dec 21 23:07

Re: Custom File Masks when assigning Stack Markers

Post by marklevine »

I pasted your suggestion into the Custom File Mask for my "JPG sidecar" stack marker but it failed to assign that marker to any images in the stack.

What coding language are you using? I can try to fix the problem myself if I knew what to investigate. Do you provide any documentation on adding code to fields like Custom File Mask? I didn't see any documentation and was really surprised (pleasantly) by your attempt to help in this way.
Hert wrote: 24 Oct 23 8:22
marklevine wrote: 23 Oct 23 18:41"JPG sidecar" Custom File Mask: %FileName.JPG
Note: I know this is wrong and needs to be corrected.
Try this as your JPG Sidecar marker's custom file mask

Code: Select all

%code 
  if ImageItem.IsJpeg then
    result := ImageItem.FileNameOnly + iif(WideTextPos('-edited', WideLowerCase(ImageItem.FileNameOnly)) > 0, NewGUID, '')
  else
    result := NewGUID;
%/code
If that works then that also holds the clue on how to do the mask for the Edited marker (which is the opposite...> 0 becomes = 0)...
Hert
Posts: 7871
Joined: 13 Sep 03 6:24

Re: Custom File Masks when assigning Stack Markers

Post by Hert »

It is inline scripting...Basically it's a macro command %code which's value is the result of a script.
PSU scripting is Object Pascal. More info about scripting can be found on the Repository page; https://repository.idimager.com/

In this particular case, I don't think you'll be able to figure it out with scripting as it requires a thorough understanding of scripting (which can take months to years to acquire), and it requires that you know how the matching takes place.

Assume you use %FileName.JPG as the mask. That means that in your case this returns:
20231006-DSCF3841.JPG

What this script does is:
1. it checks if it is a jpeg file, and if NOT then the result value is a random string (NewGUID)
2. if it is a jpeg file then
2a. If the file name contains '-edited' in the name then it adds a random string to the file name; and the result would be
20231006-DSCF3841.JPG12345678901234567890123456789012
2b. If the file name does not contain -edited then the result is the file name
20231006-DSCF3841.JPG

That means that the result of the script is only the same when it is a jpeg file and there's no -edited in the file name.

I may have overlooked something in how the detection matches results. But I expect that it compares the file name of the file being checked (20231006-DSCF3841.JPG) with the result of the matching mask (20231006-DSCF3841.JPG)...hence I expected that it should work.
This is a user-to-user forum. If you have suggestions, requests or need support then please send a message
marklevine
Posts: 55
Joined: 26 Dec 21 23:07

Re: Custom File Masks when assigning Stack Markers

Post by marklevine »

Could you explain what the file mask "First JPEG Found" is meant to return?

I'm cleaning up past work by removing all stack markers and re-assigning them. I am getting decent results with "First JPEG Found" though I had rejected that solution a long time ago. I could have committed a "user error" (Just ask my wife). I found that the original two-file stack worked with that selection but updating stack markers after verifying folders did not work properly. Perhaps I need to always delete existing stack markers before adding edited files to existing stacks.

Thoughts?

Hert wrote: 25 Oct 23 7:23 It is inline scripting...Basically it's a macro command %code which's value is the result of a script.
PSU scripting is Object Pascal. More info about scripting can be found on the Repository page; https://repository.idimager.com/

In this particular case, I don't think you'll be able to figure it out with scripting as it requires a thorough understanding of scripting (which can take months to years to acquire), and it requires that you know how the matching takes place.

Assume you use %FileName.JPG as the mask. That means that in your case this returns:
20231006-DSCF3841.JPG

What this script does is:
1. it checks if it is a jpeg file, and if NOT then the result value is a random string (NewGUID)
2. if it is a jpeg file then
2a. If the file name contains '-edited' in the name then it adds a random string to the file name; and the result would be
20231006-DSCF3841.JPG12345678901234567890123456789012
2b. If the file name does not contain -edited then the result is the file name
20231006-DSCF3841.JPG

That means that the result of the script is only the same when it is a jpeg file and there's no -edited in the file name.

I may have overlooked something in how the detection matches results. But I expect that it compares the file name of the file being checked (20231006-DSCF3841.JPG) with the result of the matching mask (20231006-DSCF3841.JPG)...hence I expected that it should work.
marklevine
Posts: 55
Joined: 26 Dec 21 23:07

Re: Custom File Masks when assigning Stack Markers

Post by marklevine »

Note that choosing "First JPEG Found" works as the rule for identifying JPG sidecars *only* works when the JPG sidecar is the displayed member of the stack. When I select an edited file as the displayed stack member, remove all stack markers, and perform stack detection, the edited file is assigned as the sidecar.

I have modified Hert's script. This also doesn't work.

Code: Select all

%code 
  if ImageItem.IsJpeg then
    result := ImageItem.FileNameOnly + iif(WideTextPos('-edited', WideLowerCase(ImageItem.FileNameOnly)) > 0, NewGUID, '') + iif(WideTextPos('-email', WideLowerCase(ImageItem.FileNameOnly)) > 0, NewGUID, '') + iif(WideTextPos('-print', WideLowerCase(ImageItem.FileNameOnly)) > 0, NewGUID, '') + iif(WideTextPos('-instagram', WideLowerCase(ImageItem.FileNameOnly)) > 0, NewGUID, '')
  else
    result := NewGUID;
%/code
marklevine wrote: 25 Oct 23 14:53 Could you explain what the file mask "First JPEG Found" is meant to return?

I'm cleaning up past work by removing all stack markers and re-assigning them. I am getting decent results with "First JPEG Found" though I had rejected that solution a long time ago. I could have committed a "user error" (Just ask my wife). I found that the original two-file stack worked with that selection but updating stack markers after verifying folders did not work properly. Perhaps I need to always delete existing stack markers before adding edited files to existing stacks.

Thoughts?

Hert wrote: 25 Oct 23 7:23 It is inline scripting...Basically it's a macro command %code which's value is the result of a script.
PSU scripting is Object Pascal. More info about scripting can be found on the Repository page; https://repository.idimager.com/

In this particular case, I don't think you'll be able to figure it out with scripting as it requires a thorough understanding of scripting (which can take months to years to acquire), and it requires that you know how the matching takes place.

Assume you use %FileName.JPG as the mask. That means that in your case this returns:
20231006-DSCF3841.JPG

What this script does is:
1. it checks if it is a jpeg file, and if NOT then the result value is a random string (NewGUID)
2. if it is a jpeg file then
2a. If the file name contains '-edited' in the name then it adds a random string to the file name; and the result would be
20231006-DSCF3841.JPG12345678901234567890123456789012
2b. If the file name does not contain -edited then the result is the file name
20231006-DSCF3841.JPG

That means that the result of the script is only the same when it is a jpeg file and there's no -edited in the file name.

I may have overlooked something in how the detection matches results. But I expect that it compares the file name of the file being checked (20231006-DSCF3841.JPG) with the result of the matching mask (20231006-DSCF3841.JPG)...hence I expected that it should work.
Hert
Posts: 7871
Joined: 13 Sep 03 6:24

Re: Custom File Masks when assigning Stack Markers

Post by Hert »

First jpeg found picks the first jpg from the collected stack.
This is a user-to-user forum. If you have suggestions, requests or need support then please send a message
marklevine
Posts: 55
Joined: 26 Dec 21 23:07

Re: Custom File Masks when assigning Stack Markers

Post by marklevine »

I'm trying to make head or tail out of your suggestion. FIrst I noted that it only deals with files containing "-edited" so I added additional NewGUIDs when the file contains any of "-email", "-instagram", et al. I think this logic is correct and it is a simple way to deal with all the additional types of edited files that might be generated. However, the script is not working.

I wonder if the failure has to do with the fact that you're stripping the file extension from the result. Note that you are basing the result on the FileNameOnly portion of the file name. I attempted to postpend the extension by adding ".jpg" or '.jpg' but neither of these caused the script to work properly. The marker identified by this script is never assigned.
Hert wrote: 24 Oct 23 8:22
marklevine wrote: 23 Oct 23 18:41"JPG sidecar" Custom File Mask: %FileName.JPG
Note: I know this is wrong and needs to be corrected.
Try this as your JPG Sidecar marker's custom file mask

Code: Select all

%code 
  if ImageItem.IsJpeg then
    result := ImageItem.FileNameOnly + iif(WideTextPos('-edited', WideLowerCase(ImageItem.FileNameOnly)) > 0, NewGUID, '')
  else
    result := NewGUID;
%/code
If that works then that also holds the clue on how to do the mask for the Edited marker (which is the opposite...> 0 becomes = 0)...
Hert
Posts: 7871
Joined: 13 Sep 03 6:24

Re: Custom File Masks when assigning Stack Markers

Post by Hert »

I had to dive into this.

The thing is that PSU tokenizes the custom mask as it expects a comma delimed list. And that tokenizes the commas used in the script.
Basically this will not work as it is.
This is a user-to-user forum. If you have suggestions, requests or need support then please send a message
marklevine
Posts: 55
Joined: 26 Dec 21 23:07

Re: Custom File Masks when assigning Stack Markers

Post by marklevine »

Hert wrote: 25 Oct 23 15:48 First jpeg found picks the first jpg from the collected stack.
In what order? It is not clear. The JPG sidecar is the first JPG in the stack when it is first imported into the catalog. That is clearly the 1st JPG Found because it is the only JPG in the stack.

If I edit an image and export two versions, say a "-edited" and a "-email", then the import will bring both new images into the stack but in what order? Will one of the new versions become the 1st JPG found? If so, which one. I don't know how to control the order with which Photolab exports images. I can (painfully) re-arrange the export order in Photolab but I'm not going to unless I understand that the new order will work with PSU to meet my wants.
Hert
Posts: 7871
Joined: 13 Sep 03 6:24

Re: Custom File Masks when assigning Stack Markers

Post by Hert »

There is no order...First JPG means exactly that: the first JPG...can be any JPG in the stack.
This is a user-to-user forum. If you have suggestions, requests or need support then please send a message
Post Reply