INTERACT FORUM

Please login or register.

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

Author Topic: Writing an Expression to Group an Album Column by Omitting Two Words  (Read 903 times)

AudibleImagery

  • World Citizen
  • ***
  • Posts: 108

Hello,

I need to write an expression (to group by) that will omit the following two words (including the brackets) from my album column: [Incomplete] & [Lossy]. For context, the reason I need to omit these words is because I use these designations to help sort these two distinct categories. These two categories can create two entries such as in the case where a lossless album has a lossy track that exists in a lossless format but that I've been unable to find in either a digital or physical format. Then I end up with 18 tracks for an album titled "Car Alarm" and one track for a separate album entry titled "Car Alarm [Lossy]". The expression is going to be written as 'Calculated data' in a custom library field that I use to sort albums: [Album] - [Album Artist]

I've been experimenting with the ListItem() expression and have gotten close by omitting one of the words but I haven't been able to figure out how to write the expression to exclude both of them. This is the expression that I've gotten closest with:
Code: [Select]
Listitem(Album, 11,0, [lossy) - Album Artist
Can somebody please help me complete this code to omit both of the words or alternatively help me to write a different code that will work?

Regards in advance,
Audible
Logged

zybex

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 2619
Re: Writing an Expression to Group an Album Column by Omitting Two Words
« Reply #1 on: February 27, 2023, 03:36:39 pm »

It's not entirely clear what you're trying to do, but I think this is what you're asking for:
trim(replace(replace([Album],/[Lossy/],),/[Incomplete/],)) - [Album Artist]

Note that this expression is case-sensitive - it works for "Lossy" and "Incomplete", but not for "lossy" or "incomplete".
Alternative case-insensitive solution:
Regex([Album],/#(.+?)(\s*\[(lossy|incomplete)\].*)?$#/,1) - [Album Artist]
Logged

AudibleImagery

  • World Citizen
  • ***
  • Posts: 108
Re: Writing an Expression to Group an Album Column by Omitting Two Words
« Reply #2 on: February 27, 2023, 07:26:48 pm »

It's not entirely clear what you're trying to do, but I think this is what you're asking for:
trim(replace(replace([Album],/[Lossy/],),/[Incomplete/],)) - [Album Artist]

Note that this expression is case-sensitive - it works for "Lossy" and "Incomplete", but not for "lossy" or "incomplete".
Alternative case-insensitive solution:
Regex([Album],/#(.+?)(\s*\[(lossy|incomplete)\].*)?$#/,1) - [Album Artist]

This did the trick! Thank you so much. How did you learn to write these expressions so well? I want to learn so that I can bother you less 😬 I've managed to write quite a few on my own but nothing this complicated.
Logged

AudibleImagery

  • World Citizen
  • ***
  • Posts: 108
Re: Writing an Expression to Group an Album Column by Omitting Two Words
« Reply #3 on: February 27, 2023, 08:19:17 pm »

I'm also trying to figure out how to group this same column by disc number because my albums currently show like this:
Code: [Select]
Feel Flows (The Sunflower & Surf's Up Sessions 1969-1971) (Disc Five)
Feel Flows (The Sunflower & Surf's Up Sessions 1969-1971) (Disc Four)
Feel Flows (The Sunflower & Surf's Up Sessions 1969-1971) (Disc Three)

but I want them to display in order of disc number like so:
Code: [Select]
Feel Flows (The Sunflower & Surf's Up Sessions 1969-1971) (Disc Three)
Feel Flows (The Sunflower & Surf's Up Sessions 1969-1971) (Disc Four)
Feel Flows (The Sunflower & Surf's Up Sessions 1969-1971) (Disc Five)
Logged

zybex

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 2619
Re: Writing an Expression to Group an Album Column by Omitting Two Words
« Reply #4 on: February 28, 2023, 03:04:23 am »

This did the trick! Thank you so much. How did you learn to write these expressions so well?

I blame my mother, she was always asking me to make funny expressions with my face. Alsho, I'm a shoftware developer and learned Lisp back when funcshional languagesh were shtill cool ::)
Try Zelda, it helps tinkering with expressions until you get the desired result. There's also a Wiki with the language ins and outs.

I'm also trying to figure out how to group this same column by disc number because my albums currently show like this:
Code: [Select]
Feel Flows (The Sunflower & Surf's Up Sessions 1969-1971) (Disc Five)
Feel Flows (The Sunflower & Surf's Up Sessions 1969-1971) (Disc Four)
Feel Flows (The Sunflower & Surf's Up Sessions 1969-1971) (Disc Three)

but I want them to display in order of disc number like so:
Code: [Select]
Feel Flows (The Sunflower & Surf's Up Sessions 1969-1971) (Disc Three)
Feel Flows (The Sunflower & Surf's Up Sessions 1969-1971) (Disc Four)
Feel Flows (The Sunflower & Surf's Up Sessions 1969-1971) (Disc Five)

Shouldn't the [Album] name be the same for these and [Disc #] be used to store the 1-2-3 disc number? Then you can use both those fields to group and sort by.
Logged

AudibleImagery

  • World Citizen
  • ***
  • Posts: 108
Re: Writing an Expression to Group an Album Column by Omitting Two Words
« Reply #5 on: February 28, 2023, 04:18:46 am »

I blame my mother, she was always asking me to make funny expressions with my face. Alsho, I'm a shoftware developer and learned Lisp back when funcshional languagesh where shtill cool ::)
Try Zelda, it helps tinkering with expressions until you get the desired result. There's also a Wiki with the language ins and outs.

Shouldn't the [Album] name be the same for these and [Disc #] be used to store the 1-2-3 disc number? Then you can use both those fields to group and sort by.

Hey I'll check out Zelda and also sit down to study the main Wiki articles about the expressions. I've done that before and so maybe if I keep reading it one day it'll finally make sense.

I don't want the album name to be the same. I don't understand why anyone would want that. Sometimes I just like to listen to a specific disc and I don't want to have to go looking through the discs to find the track and then start it that way, especially because I have some multi-disc sets that have 20 discs or so in them. I'm willing to hear your rationale but to me it seems impractical.
Logged

zybex

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 2619
Re: Writing an Expression to Group an Album Column by Omitting Two Words
« Reply #6 on: February 28, 2023, 04:48:29 am »

I don't want the album name to be the same. I don't understand why anyone would want that.
It's a matter of preference I guess. I think that a given album having 1 or 5 discs is just a consequence of the size limit of a CD, and rarely an artistic thing. If a 100-track album could fit in one CD they would publish it in one, not 7 or 10; so it's one logical Album, split in X parts. MC can still group each Disc# as a separate list anyway. And, you ARE trying to group them together...

Also, because this expression to fix that is cumbersome to say the least. Why don't you just manually rename them to numeric values like "Disc 01" so that it naturally sorts?
Code: [Select]
FirstNotEmpty(ListClean(Listmix(/#ifcase([Album]],8,disc [L1],replace([Album]],Disc [L1],Disc padNumber([N],3)))#/,0,One;Two;Three;Four;Five;Six;Seven;Eight;Nine;Ten;Eleven;Twelve;Thirteen;Fourteen;Sixteen;Seventeen;Eighteen;Nineteen;TooManyteen),3),[Album]])
Logged

zybex

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 2619
Re: Writing an Expression to Group an Album Column by Omitting Two Words
« Reply #7 on: February 28, 2023, 05:07:27 am »

There's a better way to keep your current Album names without using that eye sore expression:
- populate the [Disc #] on those albums, matching the name with the value, eg: "Best 1000 Polka Songs of the Eighties (Disc Seventy Nine)" -> set [Disc #] to 79 (you can leave Disc# blank for single-disk albums)
- Then you can use this for grouping/sorting:
  Replace([Album], /(Disc/ ,/(Disc PadNumber([Disc #], 3)/ )

.. or, populate the [Disc #], remove the "(Disc Umpteen)" from the [Album] names, and create a second calculated field called [Album (Disc #)] with expression:
  if(isEmpty([Disc #]),[Album],[Album] /(Disc [Disc #]/))

Now you have both a simple [Album] and a composite "[Album (Disc #)]" that you can use/display where needed.
Logged

AudibleImagery

  • World Citizen
  • ***
  • Posts: 108
Re: Writing an Expression to Group an Album Column by Omitting Two Words
« Reply #8 on: March 04, 2023, 05:20:20 pm »

Also, because this expression to fix that is cumbersome to say the least. Why don't you just manually rename them to numeric values like "Disc 01" so that it naturally sorts?

I decided to name them "(Disc 01), (Disc 02), (Disc 03), etc" for the time being, although I don't like how it looks.

There's a better way to keep your current Album names without using that eye sore expression:
- populate the [Disc #] on those albums, matching the name with the value, eg: "Best 1000 Polka Songs of the Eighties (Disc Seventy Nine)" -> set [Disc #] to 79 (you can leave Disc# blank for single-disk albums)
- Then you can use this for grouping/sorting:
  Replace([Album], /(Disc/ ,/(Disc PadNumber([Disc #], 3)/ )

.. or, populate the [Disc #], remove the "(Disc Umpteen)" from the [Album] names, and create a second calculated field called [Album (Disc #)] with expression:
  if(isEmpty([Disc #]),[Album],[Album] /(Disc [Disc #]/))

Now you have both a simple [Album] and a composite "[Album (Disc #)]" that you can use/display where needed.

I'm interested in implementing this solution in the near future but I want to come back to it after I've resolved a couple of issues with you from our thread about Renaming Files. One question I have though is if it would still be possible (using the above expression) to sort my folder structure with the Disc # in the folder name or folder structure?
Logged

zybex

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 2619
Re: Writing an Expression to Group an Album Column by Omitting Two Words
« Reply #9 on: March 05, 2023, 04:48:01 am »

Yes, you could then use [Disc #] or [Album (Disc #)] in the Rename/Copy tool to rename your actual folders and files if you wish.
Logged
Pages: [1]   Go Up