[Added] New Batch Action: Do (not) export if RegEx (not) matching in absolute filepath

Want to submit a new feature, an enhancement ? Do it here !
porg
Posts: 554
Joined: Tue Apr 05, 2022 1:04 pm
Country: Austria

[Added] New Batch Action: Do (not) export if RegEx (not) matching in absolute filepath

Post by porg »

User Goal:
It would be great if you could include/exclude files from the batch by evaluating not only the filename but also the path of a file.
• A simple "does (not) contain" operator helps already most cases, e.g. does not contain "/source/"
• And with a RegEx I could easily make very specific criteria like "the directory 3 levels above the file must be named medium or high" with a RegEx like: (medium|high)/[^/]+/[^/]+/$

Implementation as Batch Condition Block

The other elements in the "Conditional" section of the batch blocks have no options themselves.
So if we stick true to that "atomar building" philosophy we would need to create:
Do export if path contains
Do export if path does not contain
Do export if path matches RegEx
Do export if path doesn't match RegEx

Do not export if path contains
Do not export if path does not contain
Do not export if path matches RegEx
Do not export if path doesn't match RegEx
Or we could reduce that thing to a single block with options.

Also the differentiation "contains" and "RegEx" may not be necessary.
• As this is an expert matter RegEx would suffice. And a simple literal is a valid RegEx anyhow.
• Only thing: As the slash "/" character is the Unix path separator, you can very conveniently match along folder boundaries.
• If possible the RegEx should work without the need to escape the slash "/" character which from RegEx syntax itself is totally possible, but in some command line apps (e.g. awk) the slash itself is often reserved or at least the default to signal the start and end of a RegEx. Hence needs escaping. Needing to escape slashes for matching paths would be very badly readable and inconvenient for the task at hand.
• If you could not get around the need to escape slashes in your RegEx operator, then I'd really appreciate an additional simple "Does (not) contain" literal operator, as that does the job for many needs.
Last edited by porg on Tue Nov 29, 2022 8:43 pm, edited 4 times in total.
User avatar
forum_adm
Site Admin
Posts: 1814
Joined: Fri Dec 23, 2016 9:41 am
Location: Germany
Country: Germany
Contact:

Re: New Batch Conditions: Do (not) export if path does (not) contain / match ReGex

Post by forum_adm »

I added the following to build 5644:
Screenshot 2022-11-01 at 10.36.jpg
Screenshot 2022-11-01 at 10.36.jpg (132.75 KiB) Viewed 1107 times
porg
Posts: 554
Joined: Tue Apr 05, 2022 1:04 pm
Country: Austria

Re: New Batch Conditions: Do (not) export if path does (not) contain / match ReGex

Post by porg »

Gave it a first try. Here is my feedback.

1) Orphan folders at destination
• If "Copy folder structure" is enabled in your preferences then this works mostly correct.
• One thing it does wrong: If the RegEx filtering results in NO file output on the destination side then it nevertheless creates an orphan folder at the destination. This should be suppressed. Only created if explicitly asked for /preferred by the user.
• If as preference then in the preference next to the option "Copy folder structure" you could put the additional option "Also create empty folders at the destination".

2) Minor glitches to fix:
- Typo "Eport to", see screenshot
- In the batch table the summary reads "(null)" instead of the dialog parameters, see screenshot
- Layout optimizations, see mockup

3) Please add dialog option 🔲 Case sensitive
- which should be OFF by default, because case sensitive search is the exception on macOS, see mockup

4) Good default settings gives the user a glimpse of how this works already. Extra help is offered with help button.

a) Proposal for factory dialog preset

[ Do export ▾ ] if Regex [ matches ▾ ] [ ] case sensitive

RegEx: /[^/]*my-keyword[^/]*\.(png|jpe?g|webp|tiff)$


Design Rationale:
$ gives the expert user a hint that positional operators are regarded.
\. shows that a literal dot must be escaped
(png|jpe?g|webp|tiff) easily gives also the newbee an idea that this is a "matches one of the following" clause
jpe?g — to the expert is clear that this means "with an e or without an e"
/[^/]*my-keyword[^/]* gives an idea how to search in files containing "my-keyword" but not in folder names above.


Help text proposal:
• Path is the entire absolute filepath, that is all folders from "/" down until the filename, including its extension.
• You can chain multiple "Do or don't export if RegEx" actions in your batch. E.g. first an inclusive one like "export if regex matches" where all *.jpg *.jpeg *.png pass through files, which then gets narrowed down by an exclusive one like "filter out all that have a folder of a certain name anywhere in their path.
• In your batch you are advised to but those filename/filepath filtering actions on top which results in a reduced source list and only later in your batch have the performance intensive actions such as "Scale" etc.


Graphic Converter Export or not if RegEx 1 Orphan folders at destination.png
Graphic Converter Export or not if RegEx 1 Orphan folders at destination.png (508.49 KiB) Viewed 1103 times
Graphic Converter Export or not if RegEx 2 Minor glitches.png
Graphic Converter Export or not if RegEx 2 Minor glitches.png (53.22 KiB) Viewed 1103 times
Graphic Converter Export or not if RegEx 3 Action dialog minor redesign.png
Graphic Converter Export or not if RegEx 3 Action dialog minor redesign.png (31.58 KiB) Viewed 1103 times
User avatar
forum_adm
Site Admin
Posts: 1814
Joined: Fri Dec 23, 2016 9:41 am
Location: Germany
Country: Germany
Contact:

Re: New Batch Action: Do (not) export if RegEx (not) matching in absolute filepath

Post by forum_adm »

Please recheck with build 5646.
porg
Posts: 554
Joined: Tue Apr 05, 2022 1:04 pm
Country: Austria

Re: New Batch Action: Do (not) export if RegEx (not) matching in absolute filepath

Post by porg »

Ad 1) Orphan folders at destination → ❌ Unfixed

Ad 3) Dialog option 🔲 Case sensitive → ✅ Added to UI and works well!

Ad 2) Minor glitches to fix → ✅ Fixed → Some last improvements recommended:
Syntax for compact display of parameters:
✅|❌ if src|dest =|≠ RegEx without quotes

Examples:
✅ if src ≠ \.raw$
❌ if dest = /protected/
4a) Good factory defaults → ✅ Done.

4b) Extra help → ✅ Added as inline text (rather than help button). Kinda ok. Please make these improvements:
• Please prepend bullets to make it more readable.
• Some text had grammar-mistakes or typos.
• Also did some editorials changes.
• Bottom-padding after text block is too large.

New help text:
• Path is the entire absolute filepath, that is all folders from root "/" down until the filename, including its extension.
• ^ matches start of path, $ end of path, slash "/" must not be escaped, literal dot "." must be escaped.
• You can chain multiple "Do or don't export if RegEx" actions in your batch.
• E.g. first an inclusive one like "export if regex matches" where all *.jpg *.jpeg *.png pass through, which then get narrowed down by an exclusive one like "do not export file if a certain folder name is anywhere in its path" or more specific like "one level above" e.g. /undesired/[^/]$
• In your batch you are advised to put those filename/filepath filtering actions which result in a reduced source list on top and only later in your batch have the performance intensive actions such as "Scale" etc.
Editorial Question: The last bullet point is purely speculative. Assuming that GC's batch is dumb and unaware and simply works off the batch list as-is. But maybe GC's batch algorithm itself first performs filtering of the source/destination list and only then all the processing? If so we could remove that hint. But maybe nevertheless a good advise to leave there so that users think about proper/efficient order in a batch process.


Graphic Converter Export or not if RegEx 4 Action dialog redesign QA.png
Graphic Converter Export or not if RegEx 4 Action dialog redesign QA.png (255.2 KiB) Viewed 1080 times
porg
Posts: 554
Joined: Tue Apr 05, 2022 1:04 pm
Country: Austria

Re: New Batch Action: Do (not) export if RegEx (not) matching in absolute filepath

Post by porg »

Feedback on your initiative that the formerly static text "if path" is now an option which can be [ source path ▾ ] or [ destination path ▾ ]:

• Having the possibility to also filter on the destination path side too makes sense!
• If you have a complexly structured source as well as a complexly structured destination you may want to broadly sync over but with the destination path filtering you can determine which parts to protect or to overwrite on purpose. This gives fine grained control.
User avatar
forum_adm
Site Admin
Posts: 1814
Joined: Fri Dec 23, 2016 9:41 am
Location: Germany
Country: Germany
Contact:

Re: New Batch Action: Do (not) export if RegEx (not) matching in absolute filepath

Post by forum_adm »

Build 5647 improves the summary.
porg
Posts: 554
Joined: Tue Apr 05, 2022 1:04 pm
Country: Austria

Re: New Batch Action: Do (not) export if RegEx (not) matching in absolute filepath

Post by porg »

Remaining imporvements:
• The first parameter "export" or "export not" shall be there as "✅ " or "❌ " with one space after it. Must not be colored emojis, b/w icon glyphs are just as good, or pure plaintext "√ " or "x " at least.
• The third paramater "matches" or "matches not" shall be expressed as " = " or " ≠ " with spaces around it.
User avatar
forum_adm
Site Admin
Posts: 1814
Joined: Fri Dec 23, 2016 9:41 am
Location: Germany
Country: Germany
Contact:

Re: New Batch Action: Do (not) export if RegEx (not) matching in absolute filepath

Post by forum_adm »

I add that to build 5651 (ETA 1 day).
porg
Posts: 554
Joined: Tue Apr 05, 2022 1:04 pm
Country: Austria

Re: New Batch Action: Do (not) export if RegEx (not) matching in absolute filepath

Post by porg »

1) 👉 I see it that parameter in the output now but the text items are in the wrong order:
• Current output "if x src = myRegEx" should be "x if src = myRegEx" as in "exclude if source matches myRegEx"
• Current output "if ✓ dest ≠ myRegEx" should be "✓ if dest ≠ myRegEx" as in "include if destination does not match myRegEx"

2) 👉 Orphan folders at destination → ❌ Still unfixed

3) 👉 Help text should have prepended bullet points and the second bullet point (paragraph) was missing, please include like this:
• Path is the entire absolute filepath, that is all folders from root "/" down until the filename, including its extension.
• ^ matches start of path, $ end of path, slash "/" must not be escaped, literal dot "." must be escaped.
• You can chain multiple "Do or don't export if RegEx" actions in your batch.
• E.g. first an inclusive one like "export if regex matches" where all *.jpg *.jpeg *.png pass through, which then get narrowed down by an exclusive one like "do not export file if a certain folder name is anywhere in its path" or more specific like "one level above" e.g. /undesired/[^/]$
• In your batch you are advised to put those filename/filepath filtering actions which result in a reduced source list on top and only later in your batch have the performance intensive actions such as "Scale" etc.
Last edited by porg on Tue Nov 29, 2022 11:40 am, edited 1 time in total.
Post Reply