INTERACT FORUM

Please login or register.

Login with username, password and session length
Advanced search  
Pages: [1]   Go Down

Author Topic: Request: New ListLibrary Function for Enhanced Import Tagging  (Read 199 times)

PreLives

  • Recent member
  • *
  • Posts: 17
Request: New ListLibrary Function for Enhanced Import Tagging
« on: January 25, 2025, 11:39:22 am »

Would it be possible to implement a function that evaluates all values for a specific field across the library during the import process, allowing it to be used for matching and tagging?

I’m envisioning functionality similar to ListFind(), but instead of working with a single list, it would query the entire library. This new feature—perhaps called ListLibrary—would examine all current values in the library for a given field.

Example
  • Proposed syntax: ListFind(ListLibrary, Search, Default, Return Mode, Match Mode)
  • Example use case: ListFind([Album Artist], [Name], , 0, 1)
  • [Name] value: Bob Dylan - Like A Rolling Stone
  • Expected result: Bob Dylan (as a record for Bob Dylan already exists within the library under [Album Artist])
While I understand this could impact performance, I believe the benefit outweighs the cost for users like me who rely on filenames for tagging fields. Would such a feature be feasible? If there is already an existing function or process that can accomplish this, please let me know.

Current Workflow
Below is how I currently handle this tagging process for Keywords. It’s quite manual and involves exporting my library into Excel and performing data transformations to update the search list:

Field: Keywords
Value: =ListCombine([Keywords],IfCase([Name],8,Keyword1,Keyword1,Keyword2,Keyword2,Keyword3,Keyword3),;,;,0)
Field: Name
Value: =Replace([Name],ListItem([Keywords], 0),,1)

Field: Keywords
Value: =ListCombine([Keywords],IfCase([Name],8,Keyword1,Keyword1,Keyword2,Keyword2,Keyword3,Keyword3),;,;,0)
Field: Name
Value: =Replace([Name],ListItem([Keywords], 1),,1)

Field: Keywords
Value: =ListCombine([Keywords],IfCase([Name],8,Keyword1,Keyword1,Keyword2,Keyword2,Keyword3,Keyword3),;,;,0)
Field: Name
Value: =Replace([Name],ListItem([Keywords], 2),,1)
Logged

JimH

  • Administrator
  • Citizen of the Universe
  • *****
  • Posts: 72692
  • Where did I put my teeth?
Re: Request: New ListLibrary Function for Enhanced Import Tagging
« Reply #1 on: January 25, 2025, 11:52:31 am »

Points for presentation of your idea.
Logged

zybex

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 2769
Re: Request: New ListLibrary Function for Enhanced Import Tagging
« Reply #2 on: January 25, 2025, 03:00:57 pm »

fieldquery() can already do something similar.
There's also the F12 tool - fill properties from filename - that can be used after import.

You may perhaps use FieldQuery like this during Autoimport:

Code: [Select]
if(compare(math(int([_lastIndexedAA]-now())),<,-1),
save(FieldQuery(Album Artist,,Album Artist,0,0),_allAAs)/
save(now(),_lastIndexedAA),)/
listclean(listMix(if(compare(find([Filename],[L1]),>=,0),[L1],),0,[_allAAs]),3)

This uses FieldQuery() to collect a list (index) of all unique Album Artist values in the library, then matches the Filename against the list, returning only the items that are contained in the Filename (if any).
Because FieldQuery() can be slow, this code saves the index to a memory variable and only recalculates it once per day. That way only the first imported file will be slow, then the others should proceed at normal speed.

That said, it would be nice to have a function that returns a list of unique values for a given field, like Distinct(Album Artist). This could be cached internally by MC, like it already does for some other functions.
Logged

PreLives

  • Recent member
  • *
  • Posts: 17
Re: Request: New ListLibrary Function for Enhanced Import Tagging
« Reply #3 on: January 30, 2025, 12:28:37 pm »

Wow! This is fantastic! Thank you so much for sharing this code—it’s a complete game changer for me. I made some small changes, and for anyone else looking to adapt it, simply replace FLD with the actual field name.

Code: [Select]
=ListClean(
If(Compare(Math(Int([_lastIndexedFLD]-Now())),<,-1),
Save(ListClean(FieldQuery(FLD,,FLD,0,0),1),_allFLD)Save(Now(),_lastIndexedFLD),)
ListClean(ListMix(If(Compare(Find([Filename],[L1]),>=,0),[L1],),0,[_allFLD]),1),
3,;)

Sorting List Values by Frequency
On a separate but related note, how could I create a function that sorts list values based on their frequency in the library? For example, if a file contains the following Keywords: Nature, Photograph, Landscape, I’d like them to be automatically sorted as: Photograph, Landscape, Nature

This order is based on the number of files tagged with each keyword (e.g., Photograph appears in 10 files, Landscape in 8, and Nature in 3).

Is there an efficient way to accomplish this?

Numeric Sorting Issue in Pane View
Another issue I’ve encountered relates to sorting in a pane view. I have the following pane expression:

Code: [Select]
Math(Int(GroupCount())) / [Keywords, 1]
However, it doesn't seem to sort correctly—it appears to be treating numbers as text rather than numerical values. Any insight into why this might be happening and how to correct it would be greatly appreciated!
Logged

zybex

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 2769
Re: Request: New ListLibrary Function for Enhanced Import Tagging
« Reply #4 on: January 30, 2025, 02:37:01 pm »

Sorting List Values by Frequency
On a separate but related note, how could I create a function that sorts list values based on their frequency in the library? For example, if a file contains the following Keywords: Nature, Photograph, Landscape, I’d like them to be automatically sorted as: Photograph, Landscape, Nature

This order is based on the number of files tagged with each keyword (e.g., Photograph appears in 10 files, Landscape in 8, and Nature in 3).

With a list of all keywords, this can be used to get the counts and sort the list:
Code: [Select]
listsort(listmix(Math(listcount([_allKeywords])-listcount(listremove([_allKeywords],[L1]))) [L1],0,listclean([_allKeywords],1)),1)
The problem is obtaining that list. FieldQuery() returns only unique values, so any duplicate keywords are lost and the code above simply returns a count of 1 for each keyword. Fixing this would require adding a mode parameter to FieldQuery() to allow it to return duplicates.

Quote
Numeric Sorting Issue in Pane View
Another issue I’ve encountered relates to sorting in a pane view. I have the following pane expression:

Code: [Select]
Math(Int(GroupCount())) / [Keywords, 1]
However, it doesn't seem to sort correctly—it appears to be treating numbers as text rather than numerical values. Any insight into why this might be happening and how to correct it would be greatly appreciated!

You can't use that code on the "Expression to Group By", as the GroupCount() function can only count the items in the group after the group members are determined. You need to group by Keyword, and then use GroupCount() on the "Expression to Display".
Logged
Pages: [1]   Go Up