INTERACT FORUM

Please login or register.

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

Author Topic: More expression help please.  (Read 1807 times)

jctcom

  • Citizen of the Universe
  • *****
  • Posts: 690
  • Rush - Styx - Yes - Porcupine Tree - Staple Food!
More expression help please.
« on: July 31, 2013, 06:53:39 pm »

Ok in the day and a 1/2 or so since I have been using MC I have learned a lot.

I would like to know if the following is possible  (Actually I am sure it is.  I just need on of the 'Citizen Of The Universe' Brains on this :-)


Ok my current expression for directory rule renaming is as follows:

[ALBUMARTISTSORT]\{[Date]} [Album]      

(Created my own ALBUMARTISTSORT field which is automatically calculated thanks to help from MrC)

I have 2 file naming rules as follows:
Standard:  If(IsEmpty([Disc #],1), [Track #], D[Disc #] - [Track #]) - [Name] - [Artist] - [Album]

and
Vinyl:   [VinylTrack#] - [Name] - [Artist] - [Album]             (I created and manually populate the VinylTrack# field)

What I am looking for is 2 things.  The first I think will be easy (For you guys!)  I just don't know the secret syntax codes (I know that the whole point!)

I have created an ALBUMSUBTITLE field that I use for some albums and I would like to incorporate it into the Directory naming structure use the IfExist.  I think I could do it if the subtitle was to go before the album title  (Similar to the D# it would be an either or scenario).  but I am not sure how to do it if I want it at the end of the folder name where it is there or not there.

I think it should go something like this?  
       [ALBUMARTISTSORT]\{[Date]} [Album] If(IsEmpty([ALBUMSUBTITLE],1), [Blank], - [ALBUMSUBTITLE] - [Blank])

But I am not sure what to do to create the Blank / Empty place (Orange above)?

2nd.  This one seems a bit tougher to me but maybe (Probably) not for you guys.

I would like to amalgamate my normal file naming expression and my Vinyl naming expression.  I am sure there must be some sort of Nested if expression that could be used?

the results I am going for are as follows:

Normal CD:   Track # - Title - Artist - Album

Multi-disc CD:  D# - Track # - Title - Artist - Album

These two I (Or rather you guys) have taken care of with the expression above.

What I would like it to also do Vinyl as follows (Using my Manually entered A1, A2...B1, B2...D4, D5 etc..) in the same expression:

A1 - Title - Artist - Album    It should do the Vinyl of course only if the "VinylTrack#" field exists just as it does for the "Disc #".


Thanks again in advance for all your help.

Carl.

Oh I should also mention as it probably has some bearing.  If there is a "Disc #" there will not be a "VinylTrack#" and visa versa.  it would be either 1 or the other.  the only difference is that if there is a "Disc #" then I also need the "Track #"  if It is a "VinylTrack#" then I would not want it to include the "Track #".

Thanks again.

After making the statement above I thought I might be able to figure it out on my own and I came up with the following:

if(IsEmpty([VinylTrack#],1), If(IsEmpty([Disc #],1), [Track #], D[Disc #] - [Track #]), [VinylTrack#]) - [Name] - [Artist] - [Album]

But it isn't picking up the "VinylTrack#"   So either I mistyped something (Possibly), Or got it wrong (Probably), Or nested If Statements is not possible?  lol

Carl.
Logged
Carl's Music: https://cloud.clz.com/jctcom/music
Carl's Movies: https://cloud.clz.com/jctcom/movies

Some of Carl's Equipment:  Yamaha RX-A2A, i7-11700K, 128GB, PCIe X4 2TB M.2 SSD, GTX-970, SMSL DL200

MrC

  • Citizen of the Universe
  • *****
  • Posts: 10462
  • Your life is short. Give me your money.
Re: More expression help please.
« Reply #1 on: July 31, 2013, 07:12:05 pm »

When you want to add something to the front and/or back a value conditional upon that value being non-empty, use Delimit().

   Delimit(value, tail, head)

   [ALBUMARTISTSORT]\{[Date]} [Album]Delimit([ALBUMSUBTITLE], / -, / -/ )

For your chaining single and multi-disc CDs (untested):

ifelse(
   !isempty([VinylTrack#], [VinylTrack#]),
   1, Delimit([Disc #,0], / -/ , D)Track #) - Title - Artist - Album
)


The idea - test if VinylTrack# is not empty, and output VinylTrack#, otherwise, output a possible Disc # followed by a Track #, and all of it followed by Title, Artist and Album.
Logged
The opinions I express represent my own folly.

jctcom

  • Citizen of the Universe
  • *****
  • Posts: 690
  • Rush - Styx - Yes - Porcupine Tree - Staple Food!
Re: More expression help please.
« Reply #2 on: July 31, 2013, 07:34:03 pm »

Thanks for the quick reply.

The folder naming with or without subtitle works great!


The file naming expression will not allow me to enter it into the "Filename rule" space. 
When I tried to paste it in it ended at the "ifelse(" and left the rest blank.

Is there a reason that it is on multiple lines in your post?  Should the expression be all on a single line?  it seems like it is just skipping everything that isn't on the first line?

For your chaining single and multi-disc CDs (untested):

ifelse(
   !isempty([VinylTrack#], [VinylTrack#]),
   1, Delimit([Disc #,0], / -/ , D)Track #) - Title - Artist - Album
)


The idea - test if VinylTrack# is not empty, and output VinylTrack#, otherwise, output a possible Disc # followed by a Track #, and all of it followed by Title, Artist and Album.
Logged
Carl's Music: https://cloud.clz.com/jctcom/music
Carl's Movies: https://cloud.clz.com/jctcom/movies

Some of Carl's Equipment:  Yamaha RX-A2A, i7-11700K, 128GB, PCIe X4 2TB M.2 SSD, GTX-970, SMSL DL200

MrC

  • Citizen of the Universe
  • *****
  • Posts: 10462
  • Your life is short. Give me your money.
Re: More expression help please.
« Reply #3 on: July 31, 2013, 07:49:16 pm »

Join them into a single line code expression code.
Logged
The opinions I express represent my own folly.

jctcom

  • Citizen of the Universe
  • *****
  • Posts: 690
  • Rush - Styx - Yes - Porcupine Tree - Staple Food!
Re: More expression help please.
« Reply #4 on: July 31, 2013, 07:53:10 pm »

I put it on a single line with some slight modifications like this:

ifelse(!isempty([VinylTrack#], [VinylTrack#]),1, Delimit([Disc #,0], / -/ , D)[Track #]) - [Name] - [Artist] - [Album]

This works without errors and for "Disc #" and no "Disc #" but does not seem to do anything if there is a "VinylTrack#" there. (Seems to ignore the "VinylTrack#" field?)

Carl.
Logged
Carl's Music: https://cloud.clz.com/jctcom/music
Carl's Movies: https://cloud.clz.com/jctcom/movies

Some of Carl's Equipment:  Yamaha RX-A2A, i7-11700K, 128GB, PCIe X4 2TB M.2 SSD, GTX-970, SMSL DL200

jctcom

  • Citizen of the Universe
  • *****
  • Posts: 690
  • Rush - Styx - Yes - Porcupine Tree - Staple Food!
Re: More expression help please.
« Reply #5 on: July 31, 2013, 10:05:28 pm »

Ok.  either I am just tired and didn't test as well as I thought I did.  Or I have somehow made a change in the expression that I just can't see?

This is what I have for the Folder structure expression which I thought worked for both albums with subtitles and also for ones without:

[ALBUMARTISTSORT]\{[Date]} [Album]Delimit([ALBUMSUBTITLE], / , / -/ )

Now however it seems to work fine for albums with something in the "ALBUMSUBTITLE" field but I get an error if it is empty that reads:

"unknown ALBUMSUBTITLE" in the filename where it should be blank.

Carl.

Getting a similar error as well with the filename automation expression.
Here is what I have for the expression:
  ifelse(!isempty([VinylTrack#], [VinylTrack#]),1, Delimit([Disc #,0], / -/ , D)[Track #]) - [Name] - [Artist] - [Album]
Logged
Carl's Music: https://cloud.clz.com/jctcom/music
Carl's Movies: https://cloud.clz.com/jctcom/movies

Some of Carl's Equipment:  Yamaha RX-A2A, i7-11700K, 128GB, PCIe X4 2TB M.2 SSD, GTX-970, SMSL DL200

MrC

  • Citizen of the Universe
  • *****
  • Posts: 10462
  • Your life is short. Give me your money.
Re: More expression help please.
« Reply #6 on: July 31, 2013, 11:55:40 pm »

Whenever you use an expression for a Rename operation, you'll want to use the Raw form of field evaluation:

   [ALBUMSUBTITLE,0]

This tells MC not to output text such as "Unknown ...", and instead just outputs the raw value.  In this case, you really do want no output when the field is empty.

See if this helps.
Logged
The opinions I express represent my own folly.

jctcom

  • Citizen of the Universe
  • *****
  • Posts: 690
  • Rush - Styx - Yes - Porcupine Tree - Staple Food!
Re: More expression help please.
« Reply #7 on: August 01, 2013, 12:56:19 am »

Thank you that helped a lot.

So for the Folder path seems to be working fine with this expression:

[ALBUMARTISTSORT]\{[Date]} [Album]Delimit([ALBUMSUBTITLE,0], / , / -/ )

No more errors for the file naming. But it does not seem to be picking up the "VinylTrack#".  When there is a "VinylTrack#" present it is still using the regular track number.  It is picking up multi-disc titles properly though.

Here is what I have currently:

if(IsEmpty([VinylTrack#,0],1), If(IsEmpty([Disc #],1), [Track #], D[Disc #] - [Track #]), [VinylTrack#]) - [Name] - [Artist] - [Album]

Thank you for your help.

Carl.
Logged
Carl's Music: https://cloud.clz.com/jctcom/music
Carl's Movies: https://cloud.clz.com/jctcom/movies

Some of Carl's Equipment:  Yamaha RX-A2A, i7-11700K, 128GB, PCIe X4 2TB M.2 SSD, GTX-970, SMSL DL200

MrC

  • Citizen of the Universe
  • *****
  • Posts: 10462
  • Your life is short. Give me your money.
Re: More expression help please.
« Reply #8 on: August 01, 2013, 01:05:14 am »

Try removing the mode 1 in isempty, allowing the default mode 0 to be used.
Logged
The opinions I express represent my own folly.

jctcom

  • Citizen of the Universe
  • *****
  • Posts: 690
  • Rush - Styx - Yes - Porcupine Tree - Staple Food!
Re: More expression help please.
« Reply #9 on: August 01, 2013, 01:23:16 am »

Still testing but that seems to have done the trick!

Wooohoooo!.

Thank you.

Batch renaming is really going to be a snap now!

Carl.
Logged
Carl's Music: https://cloud.clz.com/jctcom/music
Carl's Movies: https://cloud.clz.com/jctcom/movies

Some of Carl's Equipment:  Yamaha RX-A2A, i7-11700K, 128GB, PCIe X4 2TB M.2 SSD, GTX-970, SMSL DL200

jctcom

  • Citizen of the Universe
  • *****
  • Posts: 690
  • Rush - Styx - Yes - Porcupine Tree - Staple Food!
Re: More expression help please.
« Reply #10 on: August 01, 2013, 03:07:24 am »

Ok I am going to post this here in case anyone is interested for themselves.  I have worked this out with a lot of help for Mrc and it works great.

First off what it does.  it is a single expression that will rename and move (Depending on how you have your template(s) set up). Your files (Based on their tags) into a specific set of folders / File names.  The trick was to get an expression that would work for standard single discs, Multiple discs and Vinyl in the single expression.

Here is the expression for the naming of the directories:

[ALBUMARTISTSORT]\{[Date]} [Album]Delimit([ALBUMSUBTITLE,0], /) , / /( )


Here is the expression for the files:

if(IsEmpty([VinylTrack#,0],0), If(IsEmpty([Disc #],1), [Track #], D[Disc #] - [Track #]), [VinylTrack#]) - [Name] - [Artist] - [Album]

A couple of things to note:
I have created the following fields myself as they did not exist in MC:
ALBUMARTISTSORT
ALBUMSUBTITLE   (I use this for multiple versions of an album such as "24Bit/96KHz Vinyl", "Blu-Ray" "Special Edition" etc. etc
VinylTrack#   (Not sure if these fields are case sensitive or not?)

You can of course make the fields whatever you want.  I chose some of these names because they already existed in my files / tags from previous software.

For the ALBUMARTISTSORT I have created an expression (Again with MrC's or someone else's help here) that automatically generates and fills the field based on the "Album Artist"  I will post that below for those that are interested with details on creating it.

A really interesting thing about this is that I can select a whole whack of files are are all different (Single disc, Multi-Disc, and Vinyl) and as long as they are tagged properly they will all end up in the right place with the correct naming convention (Well my correct naming convention anyways lol)

To automatically create and Album Artist Sort and an Artist sort here is what I did:

Go into Tools - Options - Library & Folders.
Click on "Manage Library Fields"   (Hopefully if you are reading up to here you have already had a bit of experience with creating your own fields (By far one of the strongest aspects to MC as far as I am concerned)
For the purposes of this discussion I created an "ALBUMARTISTSORT" field and an "ARTISTSORT" field

When you create your field everything is pretty straight forward.  Under the data field though you want to select "Calculated Data"

here is the expression for my "ALBUMARTISTSORT" field:

if(regex([Album Artist], /#(The|A|El) +(.*)$#/), [R2]/, [R1], [Album Artist])

btw I don't understand the majority of this expression.  The only thing I know for sure is it takes the "The", "A" and "El" and places them at the end of the phrase after a comma and a space.  Also if you have something else you would like to have moved in that way you can add it into the orange section with another "|" between them.
Same for "ARTISTSORT" just replace the appropriate fields

Again I did not come up with these expressions on my own (Or even mostly on my own!)  I just thought I would post this here for any other newbies like myself wanting to get this kind of functionality out of MC.

Feel free to add or change anything you want to suit your needs  (I know I do!  I have already created fields for Track Subtitle, Disc Subtitle etc.  for future plans!)

Again thank you very much to those that helped me achieve this. (You know who you are!) (He just read the earlier parts of the thread)

Hope this is useful to someone.

Have fun!

Carl.  (My first foray into expressions!)
Logged
Carl's Music: https://cloud.clz.com/jctcom/music
Carl's Movies: https://cloud.clz.com/jctcom/movies

Some of Carl's Equipment:  Yamaha RX-A2A, i7-11700K, 128GB, PCIe X4 2TB M.2 SSD, GTX-970, SMSL DL200

icstm

  • World Citizen
  • ***
  • Posts: 150
Re: More expression help please.
« Reply #11 on: August 02, 2013, 08:01:41 am »

Carl,

I think these real world examples are great, so thanks for posting and sharing.
It is such a powerful tool but the syntax is not that familar to me (esp regex), so it would be great for more of these to appear.
Logged

MrC

  • Citizen of the Universe
  • *****
  • Posts: 10462
  • Your life is short. Give me your money.
Re: More expression help please.
« Reply #12 on: August 02, 2013, 11:46:36 am »

Try these in Google:

   site:yabb.jriver.com "expression" -"Print Page"

   site:yabb.jriver.com "regex" -"Print Page"

   site:wiki.jriver.com "expression" -"Print Page"

   site:wiki.jriver.com "regex" -"Print Page"

You'll get over 9000 hits with plenty of examples.
Logged
The opinions I express represent my own folly.
Pages: [1]   Go Up