Skip to main content

Topic: Regular expressions on tags (Read 1961 times) previous topic - next topic

0 Members and 1 Guest are viewing this topic.
  • scitrek
  • [*]
Regular expressions on tags
Hi all. I have a little problem with my soudtracks collection and my iPod. As you probably know, scrolling a list very fast (through the click-wheel) in the artist / album selection pops up a letter selection menu. Since all my soundtracks files have the prefix "[OST]" in the album field, I cannot use this tool on my iPod to select a letter in the soundtrack album list.

Now, I've noticed tha in the iPod manager preferences there's the possibility to automatically edit the tags when uploading to the iPod. Right now, the album property is set to

Code: [Select]
$if2(%album%,'('None')')


Is it possible to rewrite this line to something like: when the tag starts with "[OST]" add the seventh character in front. So an album tag like "[OST] Titanic" would become "T [OST] Titanic" and so on.

Thanks so much!

  • scitrek
  • [*]
Regular expressions on tags
Reply #1
I don't know why I missed the scripting page on the FooBar wiki... I read the documentation, and I came up with this:

Code: [Select]
$if(%album%,$if($substr(%album%,0,5) IS '[OST]',$left(7,1)'pippo'),'('None')')


Does it seem right? How can I test it?

Thanks again!

  • marc2003
  • [*][*][*][*][*]
Regular expressions on tags
Reply #2
a few problems...

IS is part of the search query syntax so can't be used here. use $strcmp.

[ is a special character you'd need to wrap it in single quotes. just like the ( in the example above.

try this
Code: [Select]
$if(%album%,$if($strcmp('['OST']',$substr(%album%,0,5)),$substr(%album%,7,7) %album%,%album%),'('None')')


you can test by accessing the properties dialog of the file. right click "album", select "format from other fields", copy/paste the code and you'll get a preview.
  • Last Edit: 10 September, 2009, 08:41:23 AM by marc2003

  • scitrek
  • [*]
Regular expressions on tags
Reply #3
Thank you very much for the revision, it works perfectly now!
  • Last Edit: 10 September, 2009, 08:50:39 PM by scitrek