INTERACT FORUM

Please login or register.

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

Author Topic: expression help please  (Read 1144 times)

comox

  • Galactic Citizen
  • ****
  • Posts: 414
expression help please
« on: March 14, 2022, 06:46:43 pm »

I have some music albums accurately tagged with [Artist] & [Album].

Collection1 of albums is in Folder1.
Collection2 of albums is in Folder2.

I would like to identify all Artists in Collection2 that also exist Collection1.

Thanks for you help.
Logged

blgentry

  • Regular Member
  • Citizen of the Universe
  • *****
  • Posts: 8009
Re: expression help please
« Reply #1 on: March 15, 2022, 09:35:34 am »

I think I understand what you are trying to do.  I want to make sure though:  You are NOT trying to find duplicates.  Instead, you're trying to do some kind of comparison, probably to consolidate some artists in a single folder instead of under two folders.

So far, I have not found a way to do that.  I thought I knew how, but when I tested it, I found out I did not actually know how.

Maybe someone else has a good idea or two on this.

Brian.
Logged

comox

  • Galactic Citizen
  • ****
  • Posts: 414
Re: expression help please
« Reply #2 on: March 15, 2022, 12:31:37 pm »

Correct, I'm not trying to find duplicates.

I went through my music collection and moved all the crap albums to a cull folder. Later I realized that I want to distinguish between crap artists for which I want to cull all their albums, and crap albums of artists that have some good albums in my main collection.  I want to move all crap albums that have work by artists in my "good" collection out of the cull folder into a new folder.

Thank you very much for trying.  I will do it manually with a few hours of work.
Logged

marko

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 8959
Re: expression help please
« Reply #3 on: March 15, 2022, 12:39:37 pm »

What's inside "Folder 1" and "Folder 2"

If it's just a bunch of files, things get more complex, maybe impossible, but, if you have Folder 1\Artist\Album and Folder 2\Artist\Album then a compare might be possible...

lepa

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 1971
Re: expression help please
« Reply #4 on: March 15, 2022, 12:54:27 pm »

I guess you could use variables. So create two variables and save true (1) to variable if artist is found from your specified folder

Code: [Select]
Save(0,ArtistOnCollection1[Artist])
Save(0,ArtistOnCollection2[Artist])
If(IsEqual([Filename (Path)],Folder1),Save(1,ArtistOnCollection1[Artist]),Save(0,ArtistOnCollection1[Artist]))
If(IsEqual([Filename (Path)],Folder2),Save(1,ArtistOnCollection1[Artist]),Save(0,ArtistOnCollection1[Artist]))
Then compare if row has both locations true
Code: [Select]
If(IsEqual(Load(ArtistOnCollection1[Artist]),Load(ArtistOnCollection2[Artist])),ON BOTH, NOT ON BOTH)which can be made as filter or check mark besides row. something like that. above is not actually working and would need some adjustments but idea I guess would work
Logged

zybex

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 2416
Re: expression help please
« Reply #5 on: March 15, 2022, 01:00:14 pm »

You can use a smartlist or Search expression to find same Artist in different folders:
Code: [Select]
~nodup=[Artist],[Filename (path)] ~dup=[Artist] ~sort=[Artist],[Filename (path)]
That one shows duplicate artists in different folders (picks one of each artist+folder duplicate).

If you want to restrict it to a given pair of folders just add to the filter:
Code: [Select]
([Filename (path)]="folder1" or [Filename (path)]="folder2") ~nodup=[Artist],[Filename (path)] ~dup=[Artist] ~sort=[Artist],[Filename (path)]
"folder1" and "folder2" can be a partial folder name (contains operator), no need to enter the full path.
You can import these into a smartlist.
Logged

comox

  • Galactic Citizen
  • ****
  • Posts: 414
Re: expression help please
« Reply #6 on: March 15, 2022, 01:49:52 pm »

What's inside "Folder 1" and "Folder 2"

If it's just a bunch of files, things get more complex, maybe impossible, but, if you have Folder 1\Artist\Album and Folder 2\Artist\Album then a compare might be possible...

Albums are stored in FolderX as subfolders named [Artist] - [Year] - [Album].
Logged

comox

  • Galactic Citizen
  • ****
  • Posts: 414
Re: expression help please
« Reply #7 on: March 15, 2022, 01:51:45 pm »

Thank you lepa and zybex for excellent ideas. I will try them
Logged

lepa

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 1971
Re: expression help please
« Reply #8 on: March 15, 2022, 03:38:15 pm »

Just use zybex's solution as it is ready-made. Mine was just concept which would require some adjustments to be workable. Didn't have time to create anything ready
Logged

comox

  • Galactic Citizen
  • ****
  • Posts: 414
Re: expression help please
« Reply #9 on: March 16, 2022, 02:57:45 am »

The roots of my 2 collections are:
E:\$Media\Music\
E:\$Media\Music (culls)\

After studying the example from zybex and reading the MC documentation, I think the following should give me one file by every artist in each of the two collections:

~nodup=[Artist],Extract(6,[Filename (path)], E:\$Media\, \)

But it doesn't work.

I get one file by each artist, even if that artist is in both collections.

I'm thinking I've done something wrong with the Extract function.

Or perhaps Extract does not work with ~nodup.

Can anyone spot the problem?


Logged

zybex

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 2416
Re: expression help please
« Reply #10 on: March 16, 2022, 03:56:42 am »

Have you tried the first expression (without any folder filter)? It should work, unless you have more collections that you want to keep out of the results.

You need both the ~nodup and the ~dup as I pasted on the previous post, and their order is important.
You can just use the folder names directly - just paste this into the Search box:
Code: [Select]
([Filename (path)]="E:\$Media\Music\" or [Filename (path)]="E:\$Media\Music (culls)\") ~nodup=[Artist],[Filename (path)] ~dup=[Artist] ~sort=[Artist],[Filename (path)]
Logged

comox

  • Galactic Citizen
  • ****
  • Posts: 414
Re: expression help please
« Reply #11 on: March 16, 2022, 11:37:55 am »

Thanks for your help. Yes I did try it.

It returns 1 file for every album by every artist from both collections, which is not helpful.

I want 1 file by every artist from both collections.

I think this is understandable since my tracks are named:
E:\$Media\Music\[Artist] - [Year] - [Album]\[Track #] - [Name]
E:\$Media\Music (culls)\[Artist] - [Year] - [Album]\[Track #] - [Name]

That's why I'm trying to get the extract function to work.

As a simple test to figure out what's going on I tried:

~nodup=Extract(6, [Filename (path)], E:\$Media\, \)

I expected 1 file from each collection. Instead it returns zero files.

Any tips on getting Extract to work?




Logged

zybex

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 2416
Re: expression help please
« Reply #12 on: March 16, 2022, 11:50:35 am »

You said "I have some music albums accurately tagged with [Artist] & [Album]". I'm assuming you mean the [Artist] field is accurate for all tracks, regardless of what the folder name is called. If you're trying to search based on the actual folder names then it's a whole different expression.

Quote
It returns 1 file for every album by every artist from both collections, which is not helpful.
Where are you putting the expression? This is not to be used as an "expression column', it's a filter to enter in the Search Omnibox (top right corner), or to Import into a Smartlist. It does not return any value, it just filters the View.

The expression as I gave you does return one file per [Artist] from each folder, for all artists that exist in both folders (artists present in just one folder are filtered out). Check the screenshot below.
If you instead want per [Album Artist], just change the expression accordingly. And again, note that this only works if your fields in MC are properly tagged.

Quote
As a simple test to figure out what's going on I tried:

~nodup=Extract(6, [Filename (path)], E:\$Media\, \)
This is not a valid Search Expression, and also not a valid Expression for a field/column. You can't mix Search modifiers like ~nodup with an Expression function like that. You can use functions in the search box, but not with that syntax and probably not to accomplish what you want.
Logged

comox

  • Galactic Citizen
  • ****
  • Posts: 414
Re: expression help please
« Reply #13 on: March 16, 2022, 02:13:51 pm »

Yes, [Artist] is accurately filled for all tracks.

I am putting the expression in the search omnibox of a view that shows all of my music tracks.

The expression as I gave you does return one file per [Artist] from each folder, for all artists that exist in both folders (artists present in just one folder are filtered out). Check the screenshot below.

I agree, the problem I think is that every album has a unique [filename (path)] (see above for how albums and tracks are named) and so I get one file for every album rather than one file for every artist. That's why I was trying to extract the relevant substring from the path.

Reading the documentation on the Search Language and Functions I see no mention that functions cannot be used with the Search Language.

I'm out of ideas if I cannot use Functions.

Not the end of the world. I'll do the work manually. Thanks for your help.
Logged

zybex

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 2416
Re: expression help please
« Reply #14 on: March 16, 2022, 02:37:35 pm »

Perhaps I misunderstood your request. The filter above shows one file per folder if there's another file in a different folder with the same Artist (any pair of folders). It sounds like you want to intersect the list of Artists in your "Music" collection with the list of Artists from the "Music (culls)" collection, but without considering duplicate artists within the same collection/tree, which is not exactly the same thing.

This is still possible. Just create a Calculated field called "Collection" with the following expression:
Code: [Select]
if(isEqual([filename], /(culls/)\, 8), Culls, Music)
Then use this filter:
Code: [Select]
~nodup=[Artist],[Collection] ~dup=[Artist] ~sort=[Artist],[Collection]
This will only show pairs of files with the same Artist where one of them is in the Culls collection and the other is not.
Logged

comox

  • Galactic Citizen
  • ****
  • Posts: 414
Re: expression help please
« Reply #15 on: March 16, 2022, 03:25:53 pm »

Excellent idea. Worked perfectly. Thank you!

Damn MC is a powerful program.

Maybe Matt can make functions work with search in his spare time. :)
Logged
Pages: [1]   Go Up