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?
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
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”
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 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
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