INTERACT FORUM

Please login or register.

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

Author Topic: Beginner Expression Language Question  (Read 7884 times)

baconbrain

  • Recent member
  • *
  • Posts: 5
Beginner Expression Language Question
« on: August 29, 2014, 02:35:06 pm »

Hello,

I am encountering a small challenge with renaming multiple albums by adding a sample rate suffix in the album file at the end of the existing album name. When using the expression =[Album] /(24-96/) it ends up replacing the entire album name instead of just adding the suffix. Checked the wiki without much success and was hoping someone could point me in the right direction? Thx!
Logged

mwillems

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 5234
  • "Linux Merit Badge" Recipient
Re: Beginner Expression Language Question
« Reply #1 on: August 29, 2014, 02:53:17 pm »

Hello,

I am encountering a small challenge with renaming multiple albums by adding a sample rate suffix in the album fiel at the end of the existing album name. When using the expression =[Album] /(24-96/) it ends up replacing the entire album name instead of just adding the suffix. Checked the wiki without much success and was hoping someone could point me in the right direction? Thx!

I'm not a regex expert, but aren't your escape slashes in that expression the wrong way around?  By which I mean you seem to have used forward slashes to escape the parentheses instead of backslashes?
Logged

baconbrain

  • Recent member
  • *
  • Posts: 5
Re: Beginner Expression Language Question
« Reply #2 on: August 29, 2014, 03:10:45 pm »

Thanks for the prompt feedback but the wiki states: "The forward-slash escape character / disables the special meaning of the character that follows it." Another idea?
Logged

mwillems

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 5234
  • "Linux Merit Badge" Recipient
Re: Beginner Expression Language Question
« Reply #3 on: August 29, 2014, 03:26:22 pm »

Thanks for the prompt feedback but the wiki states: "The forward-slash escape character / disables the special meaning of the character that follows it." Another idea?

Have you tried it without the slashes?  To be clear, I'm not on a Mac (I'm on Linux), but when I try entering your string into the "Rename Move Replace" dialog it seems to be parsing the forward slashes as indicating an additional subdirectory rather than as escape characters (it's using the [album] portion to create another layer of subdirectories).  When I enter "=[album] (24-96)" in the file window (no quotes), I get the correct result.  

The wiki says that "To use a literal parenthesis, comma, or whitespace inside of function argument lists, escape them [emphasis added]"; this context is not a function argument list so perhaps it needs no escaping.

You can see how the rename tool will parse your expression before commiting by looking at the "new" column in the option window.
Logged

baconbrain

  • Recent member
  • *
  • Posts: 5
Re: Beginner Expression Language Question
« Reply #4 on: August 30, 2014, 03:41:45 pm »

Ha, it works!!!

Next I would like to replace an existing suffix in an album title with something else. Is it possible to use the replace function with =[Album] ?

Really appreciate the help. :)
Logged

mwillems

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 5234
  • "Linux Merit Badge" Recipient
Re: Beginner Expression Language Question
« Reply #5 on: August 30, 2014, 05:09:20 pm »

Ha, it works!!!

Next I would like to replace an existing suffix in an album title with something else. Is it possible to use the replace function with =[Album] ?

Really appreciate the help. :)

I'm not 100% sure what you're asking; if you enter the search string for what you want to find in the appropriate box on the Rename/Move/Copy dialog, you can replace it with whatever you like (and see what the results will be in the "new" column before committing the change).  If you mean can you effectively do a find and replace on an album title using the [album] field in the replace term (rather than in the find term), I think that can only be additive (you can only add to the name, not subtract from it). 

But I'm not sure what you're asking, maybe you could explain in more detail what you're trying to do?
Logged

baconbrain

  • Recent member
  • *
  • Posts: 5
Re: Beginner Expression Language Question
« Reply #6 on: August 30, 2014, 05:58:43 pm »

Thanks for your patience. Honestly I have not been using the rename/move/copy dialog via Library tools. I have tweaked a pane which allows me to sort my albums by sample rate. I then select multiple albums out of this view which I want to modify and do so via the album field in the tagging tool using expressions like discussed earlier. Currently I have some albums which have the suffix HR (for high resolution) at the end of the title. I would now like to replace the HR suffix with the specific sample rate such as 192-24. Hope you follow what I am trying to do.
Logged

mwillems

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 5234
  • "Linux Merit Badge" Recipient
Re: Beginner Expression Language Question
« Reply #7 on: August 30, 2014, 06:01:23 pm »

Thanks for your patience. Honestly I have not been using the rename/move/copy dialog via Library tools. I have tweaked a pane which allows me to sort my albums by sample rate. I then select multiple albums out of this view which I want to modify and do so via the album field in the tagging tool using expressions like discussed earlier. Currently I have some albums which have the suffix HR (for high resolution) at the end of the title. I would now like to replace the HR suffix with the specific sample rate such as 192-24. Hope you follow what I am trying to do.

The easiest way I know to do it is to select the files you want to fix, open the rename/move/copy dialog and enter "HR" in the "find" field and "192-24" in the "replace" field.  Check the preview to make sure it's working the way you want, and commit.  Easy peasy.
Logged

6233638

  • Regular Member
  • Citizen of the Universe
  • *****
  • Posts: 5353
Re: Beginner Expression Language Question
« Reply #8 on: August 31, 2014, 04:03:55 am »

Currently I have some albums which have the suffix HR (for high resolution) at the end of the title. I would now like to replace the HR suffix with the specific sample rate such as 192-24. Hope you follow what I am trying to do.

Code: [Select]
=RemoveRight([Album],3)Delimit(Math([Sample Rate,0]/1000)-[Bit Depth],/),/ /()
Logged

baconbrain

  • Recent member
  • *
  • Posts: 5
Re: Beginner Expression Language Question
« Reply #9 on: September 01, 2014, 04:23:36 pm »

So, tried find & replace via Library Tools and it was straight and to the point. The only disadvantage being that one has to select each individual title (or multiple via shift) which becomes somewhat clumsy when wanting to make the replacement over numerous albums.

Looking forward to trying the creative code suggestion from 6233638. Curious if it would also work with =addright instead of remove?
Logged
Pages: [1]   Go Up