category to attributes

Started by David Werier, June 12, 2014, 10:25:33 PM

Previous topic - Next topic

David Werier

In IMatch 3 I used a script to populate some properties with parts of my category tree. The script was written by khodadad. The script is called "write category parts to property". It really is an amazing script. The idea was to get very specific information out of my category tree into particular attributes (called properties in IMatch 3) and then use these attributes for various purposes including using them to sort, rename files, and as text on an image.

Anyway, I am wondering if in IMatch 5, there is some new functionality that will allow me to accomplish the same thing without using a (this) script? It could either be a way to get parts of my categories into particular attributes or use parts of my categories for the purposes I mentioned above (i.e. to sort by, rename files, and to use as text on an image).

My post (http://ptforum.photoolsweb.com/ubbthreads.php?ubb=showflat&Main=8270&Number=52667#Post52560) from the old forum discusses this more.

Thanks in advance for any help anyone can provide.


Mario

This is indeed a very specific and purpose-built feature.

You can use the Copy Metadata into Attributes script to copy everything that can be accessed via a variable into Attributes. Check out the numerous features of variables in IMatch, especially the ones which deal with categories. Use the Var Toy app for easy testing.

+ The Renamer supports variables anyway.
+ The Batch Processor supports variable anyway for overlays.
+ Sorting supports metadata tags and Attributes.

No need for scripting as far as I see it. Make yourself acquainted with variables in IMatch 5, they have learned many new tricks.
-- Mario
IMatch Developer
Forum Administrator
http://www.photools.com  -  Contact & Support - Follow me on 𝕏 - Like photools.com on Facebook

David Werier

Absolutely amazing Mario. Very nice work. These attributes are perfect and I can basically specify exactly the items in my database I am looking for. I just did a large rename file name project and it worked perfect. So thanks for all these improvements. Really nice. :)

One thing I can't figure out and perhaps it is a bug but I guess I don't know.

Here is the example
My Category tree contains
Person.John.Doe
as well as
Person.Jane.Marie

I am trying to get the result:  John Doe; Jane Marie

What I have tried

{File.Categories.Direct|filter:^Person;level:1} {File.Categories.Direct|filter:^Person;level:2}

This returns John;Jane Doe;Marie

So I tried the index function

{File.Categories.Direct|filter:^Person;level:1;index:0} {File.Categories.Direct|filter:^Person;level:2;index:0};
{File.Categories.Direct|filter:^Person;level:1;index:1} {File.Categories.Direct|filter:^Person;level:2;index:1}

But I think I must be using the index function wrong because it doesn't seem to change anything.

So I guess first off, is it possible to achieve what I am trying to achieve? If so how should I go about this?


Mario

I tried your example. I created a Person category hierarchy. Assigned a file to both the Doe and Marie categories.
The output of your variable looks correct:



[attachment deleted by admin]
-- Mario
IMatch Developer
Forum Administrator
http://www.photools.com  -  Contact & Support - Follow me on 𝕏 - Like photools.com on Facebook

David Werier

Thanks Mario for working on my post.

Notice that John is supposed to be a category and Doe is a sub category of that. Same with Jane being a category and Marie being a sub category. You have John Doe as one category and Jane Marie as another.

I realize with peoples names that is the way that one would normally creates the hierarchy but I am actually working with scientific names where I place the genus as one category and specific epithets as child categories. See the first attachment for an example. What I want the result to be is Panax trifolia; Aralia nudicaulis.

I also have an example with people names to make the language a little easier to work with. See the 2nd attachment. For that one I want the result to be John Doe; Jane Marie.





[attachment deleted by admin]

Mario

I'm still not sure what it is what you want. If you want to extract the bottom two levels of your category tree, use something like

{File.Categories.Direct|filter:^plants;level:-2} {File.Categories.Direct|filter:^plants;level:-1}

which gives you the leaf level and the level above that. This gives you Panax trifolia or the other one.
-- Mario
IMatch Developer
Forum Administrator
http://www.photools.com  -  Contact & Support - Follow me on 𝕏 - Like photools.com on Facebook

David Werier

Quote from: Mario on June 15, 2014, 07:12:39 PM
I'm still not sure what it is what you want. If you want to extract the bottom two levels of your category tree, use something like

{File.Categories.Direct|filter:^plants;level:-2} {File.Categories.Direct|filter:^plants;level:-1}

which gives you the leaf level and the level above that. This gives you Panax trifolia or the other one.

The idea is that I want both full names (i.e. Panax trifolia and Aralia hispida or in the people example John Doe and Jane Marie).

I tried your suggestion and it still gives me:

Panax;Aralia; trifolia;hispida

when I want:
Panax trifolia; Aralia hispida
see attachment

With the people example it gives me:
John;Jane; Doe;Marie

when I want:
John Doe; Jane Marie
see attachment

Does this make sense?



[attachment deleted by admin]

Mario

Please export your categories, zip and attach.
I have re-created your tree from your screen shot and it works here.

You cannot get Panax;Aralia; using my expression because it takes the bottom level, then <blank>, then the level above bottom.
-- Mario
IMatch Developer
Forum Administrator
http://www.photools.com  -  Contact & Support - Follow me on 𝕏 - Like photools.com on Facebook

David Werier

My categories are attached as a zip. This is just a test database that was I was using to illustrate what was going on for me. It also goes on in my main database.



[attachment deleted by admin]

Mario

I see your problem now.

You are assigning two or more categories to your file. Your "people" file has these categories:

people|John|Peters
people|Jane|Marie


Category variables return all categories for an image, so the unrestricted result for your file is:

people|John|Peters ; people|Jane|Marie

Two categories are returned, separated by semicolon.

If you now restrict the level somehow, this is still applied to each of the categories assigned to the image. Then the result is again returned in list form. E.g., for

{File.Categories.Direct|filter:^people;level:2}

the result is

Peters;Marie


You cannot combine multiple levels into one text for each of the returned category names (e.g., to form "John Peters"). Level etc. are applied to each category before they are returned. We would need a formatting function which not picks one level out of the hierarchy, but allows you to specify from which level, up or down, how many levels you want to extract. But that would be a feature request, so please feel free to add one.

As a work-around for your problem, try this:

{File.Categories.Direct|filter:^people;replace:people~|==;replace:~|== }

This gives you

John Peters;Jane Marie

The formatting function replaces the people| in the returned string with nothing. And it replaces | with a blank.


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

David Werier

Thanks Mario for spending all this time with this.

I will try your work around and make a feature request.

FYI Kodadad's write category parts to property script did what you mentioned. It allowed you to choose a tier within the category tree and go up or down the hierarcy for as many levels as you specified. This for each return. Therefore, if two or three or how every many items were assigned to the same tier it allowed for each iteration a return of more than one tier. Hard to explain but I think you get the point. Like I mentioned in my first post in this topic, his script really was masterfully done. Still, your new system is quite nice too and produces amazing results.

Thanks again.