Export from categories

Started by frankdarwin, October 13, 2024, 11:01:53 PM

Previous topic - Next topic

frankdarwin

Hello,
I have assigned photos that I want to publish to a category with subcategories.

Now I want to export all photos of all subcategories to the file system.

Is it possible to automatically create a file system structure during the export that corresponds to the hierarchy of the main category?

Frank

Mario

How to you "export" files? Which feature do you use?
Renamer? Batch Processor?
Both support creation of folder names on-the-fly using variables, so you need to somehow transform your category hierarchy into folder names using category variables. Use the VarToy to test.
-- Mario
IMatch Developer
Forum Administrator
http://www.photools.com  -  Contact & Support - Follow me on 𝕏 - Like photools.com on Facebook

frankdarwin

Hello,
I would like to use the Batch Processor.
After calling it up, I have made the settings as in "Einstellungen Batch Prozessor.jpg".
After execution I get the message as shown in "Fehler Batch Prozessor.jpg".
Where is my error?
Have I selected the wrong variable?
Why is the output directory not created?

Frank

thrinn

The expression you use to generate the filename does not generate valid names. {File.Categories.Direct}{File.Name}
will result in something like
Test|Beach|Daytona2023-06-14-035The "|" is not a valid character for a Windows file name.

Instead, use this expression in the Output Folder field:
D:\_tmp\{File.Categories.Direct|replace:~|==~\}This will replace the category separator | with a backslash, thus generating a valid path.
As File name, just use the {File.Name} expression.
Thorsten
Win 10 / 64, IMatch 2018, IMA

frankdarwin

Quote from: thrinn on October 19, 2024, 10:09:35 AMThe expression you use to generate the filename does not generate valid names. {File.Categories.Direct}{File.Name}
will result in something like
Test|Beach|Daytona2023-06-14-035The "|" is not a valid character for a Windows file name.
Instead, use this expression in the Output Folder field:
D:\_tmp\{File.Categories.Direct|replace:~|==~\}This will replace the category separator | with a backslash, thus generating a valid path.
As File name, just use the {File.Name} expression.

Hello,
thanks for the tip.
It does work, but it has a small flaw.
Windows directories are created whose name contains a ";". The individual sections of the name indicate the categories in which the photos are located.

Erstellte Windows Verzeichnisse.jpg

This is not really useful.
That's why I experimented a bit with the variables and found a solution that I like better.

I used the following variable:

{File.Categories.DirectNoAlias|level:-1}\{File.Categories.DirectNoAlias|level:1}

However, the solution is still not optimal.

The 7 photos I selected for test purposes in IM are in more than one category.

In the directory "Für Fotobuch" there are 2, in the directory "_Mein Workflow" (again a directory name with ";") there are 5 of the selected photos.


Erstellte Windows Verzeichnisse mit eigener Variablen.jpg


My aim is to export all the photos from the "Für Fotobuch" category in such a way that the directory structure is displayed in Windows in exactly the same way as the category structure.

I have no idea which of the variables, or a combination, I need to select to achieve this.


BTW: Which scripting language is the command "{File.Categories.Direct|replace:~|==~\}" about?


Mario

Did you try your category variable in VarToy?

Because, if a file has multiple categories (as you said it has), the category variable (without using a filter) outputs all categories of the file, separated with a ;

Which indicates that you just use a category variable, but you don't filter it for the category you actually want to use.
Start here: File.Categories and use VarToy to show you what your variable returns. I said so in my initial reply.
-- Mario
IMatch Developer
Forum Administrator
http://www.photools.com  -  Contact & Support - Follow me on 𝕏 - Like photools.com on Facebook

thrinn

Quote from: frankdarwin on October 19, 2024, 09:16:42 PMBTW: Which scripting language is the command "{File.Categories.Direct|replace:~|==~\}" about
This is not a scripting language. It is just the way IMatch variables can be used, specifically their formatting functions.
Thorsten
Win 10 / 64, IMatch 2018, IMA

frankdarwin

Yes,
I have tested with VarToy.
But no category variable or combination of them produced the desired result.

Quote from: Mario on October 19, 2024, 09:38:36 PMbut you don't filter it for the category you actually want to use.
I have read everything in IM Help - Variables. But under "Formatting Functions" I didn't find (or didn't recognize) anything that would help me.
I will describe again what I want to achieve:
In the category "Für Fotobuch" there are photos that are divided into the following subcategories:


Ketegorie.jpg

I would like to export all photos to directories that have the same name as the categories. The directory structure should be identical to the category structure.
Here is an example of my tests with different category variables.

The variable "{File.Categories.Direct}" gives the following result:

_Mein Workflow|1 Neue Fotos;Für Fotobuch|Sonstiges

The target directory in Windows should be "Fotobuch\Sonstiges".
I have no idea how to create a filter that produces the desired result.

Can you or anybody perhaps help me with a suitable example?

If it's too time-consuming, I'll accept that and do my exports manually.

Thanks for the support anyway!

thrinn

I believe the following expression should achieve what you want:
D:\_tmp\{File.Categories.Direct|filter:^Für Fotobuch;replace:|==\}
In comparison to the expression I provided in my earlier post, I added a "filter" formatting function. To explain: File.Categories.Direct will return all categories the file is assigned to.  The filter:^Für Fotobuch restricts the result to categories starting with Für Fotobuch. This should get rid of all other categories you don't want to have as part of the destination directory structure. The last part, replace:|==\ , replaces the hierarchy separator by a backslash as before.

If you use this setting, you should be fine. To avoid issues with the generated structure, just make sure that you only use "regular" characters in your category names which are also allowed as part of a directory name in Windows.
2024-10-21 07_51_09-IM Test 01.imd5.jpg
Thorsten
Win 10 / 64, IMatch 2018, IMA

Mario

@thrinn: well done! Thanks for helping.
Variables are indeed very powerful :D
-- Mario
IMatch Developer
Forum Administrator
http://www.photools.com  -  Contact & Support - Follow me on 𝕏 - Like photools.com on Facebook

frankdarwin

Many, many thanks for your support!
Now everything is just as I imagined it :) :)
I agree with Mario. Variables are very powerful!

Maybe I'll manage to delve deeper into their secrets and possibilities after all.

I'm working on it.

Mario

Quote from: frankdarwin on October 21, 2024, 11:59:18 AMMaybe I'll manage to delve deeper into their secrets and possibilities after all.
If you're planning to do more advanced things like using some of the categories assigned to images to dynamically creating a folder hierarchy when exporting files with the Renamer or Batch Processor, some deeper knowledge about variables will be very helpful.
-- Mario
IMatch Developer
Forum Administrator
http://www.photools.com  -  Contact & Support - Follow me on 𝕏 - Like photools.com on Facebook