More > JRiver Media Center 21 for Windows

Tag manipulation with expression language

(1/3) > >>

jacobacci:
Hi all,
I am new to using the expression language and I'm looking for some pointers to shorten the learning curve.
I have converted all my SACD ISOs to PCM. MC tags the PCM files with the tags the ISOs have in the library. This means the files show up as duplicates in MC, as artist, album, title etc. are identical.
I would like to add the letters "DS" (as in down sampled) to the album tag of the PCM files. My ISO album tags are "D_xxxxxxx". As I want to be able to run the script also after some of the files already have the DS prefix, I need to make the addition conditional. Functionally the script should do the following

- See if the album Tag of the file starts with D_
- if yes, add DS in front of it
- if not, do nothing
- do this for all files in a particular directory

How do I best go about doing this? I have read that I can add an expression column to the view of the folder where the files reside. Is this the best way to do this?

Thanks a lot

blgentry:
First you'll want to be able to select the group or groups of files you want to operate on.  Personally, I would use the Audio > Files view for this.  You can choose a directory from the Location pane.  You can even make it a parent directory if you have lots of these to do.  Next, I'd use the File Type pane to remove all SACD files.  Select the file type(s) that you want to rename and of course leave out SACD so it doesn't get selected.

As for actually re-writing the album tag, you can definitely use expressions.  There are probably several ways to do it.  Here's an expression I just tested to do what you're asking for:


--- Code: ---if(compare(regex([Album], /#^D_(.+)$#/,0,0), =,1), DS_[R1], [Album])
--- End code ---

This works on the [Album] tag.  If you want to apply this to a different tag, you'll need to change the expression appropriately.

To test this out, make a new expression column and paste this expression into it.  Then review it's values for the albums you are talking about.  Make sure it looks correct.  To apply this to the [Album] tag here's the procedure:

1.  Select some files you want to change.  Start with a small test group.  If it doesn't work, use undo to reverse the changes right away.
2.  Press Alt-enter, or right click to select "Tag".  The tagging pane will appear on the left.
3.  Find the Album tag and click in it to highlight it.  You are now editing that tag for all selected files.
4.  Paste in the expression with an = sign in front of it.  Like this: 
--- Code: ---=if(compare(regex([Album], /#^D_(.+)$#/,0,0), =,1), DS_[R1], [Album])
--- End code ---
5.  Press enter to make the changes.
6.  Review to make sure the changes worked.  If not press control-Z to undo.  Or Edit > Undo

You can work on a larger group, or the whole thing after you've done a test or two.

NOTE:  This changes the [Album] tag in all of the files you are working on.  It does NOT change the filename.  To change the file name, you would need to use the Rename, Move, and Copy tool *after* you make these changes to the Album tag.  We can help you with that also if necessary.

Good luck.  Let us know how you do and/or if you need any help tweaking this to work for you.

Brian.

ferday:
i would do it blgentry's way because i like regex.

but to offer an alternative, you can do this in the JRiver built in expression language as well, which may help you learn the 'basics' a little better (regex is not basic LOL)

instead of blgentry's code, you can paste in this code (in the album field or a new expression column):


--- Code: ---if(isequal(left([Album],2),d_,1),DS-[Album],[Album])
--- End code ---

if you want to do another field than album, change as needed.  the rest of blgentry's excellent comments apply, it does NOT change anything on disk.  you can either paste it in to an expression column (right click, add expression column) or paste in to the tag field you want to change.

personally, i'd paste it in to an expression column (let's call it DS), then i could see the changes.  then i'd go in to the tag window if i was happy and type into the [album] field


--- Code: ---=[DS]
--- End code ---

blgentry:
Reading Ferday's post, I realized that the requirement isn't exactly clear.  Ferday and I have read it two different ways.

I read it to mean that he wants to transform this way:

D_The_Great Album ---->  DS_The_Great_Album

I think Ferday read it as:

D_The_Great_Album ----> DS-D_The_Great_Album

Can you give an example of what you are trying to do so we can be sure?

Ferday:  Not trying to pick on you at all buddy.  I was reading your code because I wanted to understand more about the other functions in the Expression Language and saw the differences.  I'm not 100% sure what the original poster really wants, so I'm asking him to clarify.

Thanks,

Brian.

ferday:
ha ha ha no worries at all, if i didn't have my code picked apart i wouldn't get better at it.  i never though about wanting to remove the current d_ which of course i would've then been irritated at having, so thanks for pointing it out!

if he wanted your scenario then this should work


--- Code: ---if(isequal(left([Album],2),d_,1),replace([album],D_,DS-),[Album])
--- End code ---

which would output D_name.iso to DS-name.iso.  of course replace the dash with _ or whatever...i hate underscores so i use dashes more often ;)
i've only tested this with one album (renaming it to D_album) FYI

if the album name gets much more complex than just D_name.iso, the built in language will start to fail a bit.  as i said i like the regex solution but it's good to show a few ways of doing it IMO

Navigation

[0] Message Index

[#] Next page

Go to full version