RegExp search in iTunes?

Hi there

I’m trying to populate an iTunes playlist through specific search terms and I’m getting frustrated by the “search playlist” function. It replicates the iTunes search bar, which as far as I know do not allow the use of wildcards and strict search terms, let alone Regular Expressions

For example, if I search for BWV 33 it will display results containing either BWV or 33 or aBWV or 133 or 334 or… What I want is really “BWV 33”.

Here’s the part of my script that uses the search function:


repeat with cantata in BWVslist
	set FoundTracks to search playlist "Library" for "BWV " & cantata
	repeat with NewTrack in FoundTracks
		duplicate NewTrack to Cantatalist
	end repeat
end repeat

(the variable cantata contains a number, 33 in the above example)

Is there another way to do a “power search” in iTunes tracks?

Thanks an awful lot!

You might want to use whose rather than search

tell application "iTunes"

	set FoundTracks to get tracks of playlist "Library" whose artist = "Grateful Dead"
	
	set FoundOtherTracks to get tracks of playlist "Library" whose artist begins with "Grateful"
	
end tell


Hi,

I use a smart playlist for my Bach cantatas, I organized the tracks by writing “Cantata xx” into the album field and volume of the CD into the Grouping field. The criteria for the smart playlist is
¢ Album starts with “Cantata” and
¢ Composer is “J. S. Bach”

btw: BWV 33 is “Allein zu dir, Herr Jesu Christ” :wink:

Hey, thanks for all your answers!

I indeed thought of circumventing the problem, renaming all my cantatas beginning with the BWV number and then doing something like


tell application "iTunes"
   
   set FoundTracks to get (tracks of playlist "Library" whose album begins with "BWV " & cantata & " -")
   
end tell

But I wanted to try something smarter first :slight_smile: Turns out it isn’t possible. Renaming the tracks will do the trick.

StefanK: I already have a smart playlist for cantatas. I’m writing this script to automatically populate a playlist with the cantatas for next sunday according to the Lutheran church year. For example, my playlist now contains all Easter cantatas :slight_smile:
If you’re interested, I’ll post the whole script here once it’s finished. For now, I’m cheating by using a predefined list of dates, but I intend to put all logic within the script (Easter date calculation and so on). Stay tuned :slight_smile:

Thanks again.