Iterated playlists in iTunes

iTunes doesn’t make it easy to build playlists with multiple iterations of the same track. You can do it; but with every addition iTunes puts up a dialog box and asks you if you indeed intent to do it. It’s an annoyance.

I wrote a short AppleScript that allows you to build a playlist built with multiple iterations of a group of selected tracks. The script allows you to specify the name of the playlist and how the tracks are to be added (all of the iterations of one track back-to-back [AAABBBCCC] or repetitions of each group of tracks. [ABCABCABC]) Read more after the break.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
(*

Suzuki maniac playlist generator

Based on the idea of Michelle Horner's "Listening like a maniac", basically
saturation listening to the Suzuki repertoire surrounding the piece you are
currently working on.

Copyright (c) 2015 Alan K. Duncan

Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do
so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.


*)


tell application id "com.apple.iTunes"
-- ensure we have a selection
set theTracks to the selection
if theTracks is {} then error "Please select tracks."

-- get the user's choices
set plTitle to my getPlaylistTitle()
set iterCount to my getIterations(10)
set arrangementButton to my getArrangement()

-- create the new playlist
set pl to make new user playlist with properties {name:plTitle}

-- arrange the tracks depending on the user's requested style
if arrangementButton is "Sequentially" then
repeat with aTrack in theTracks
repeat iterCount times
duplicate aTrack to pl
end repeat
end repeat
else
repeat iterCount times
repeat with aTrack in theTracks
duplicate aTrack to pl
end repeat
end repeat
end if
end tell

on getPlaylistTitle()
set introText to "Name of playlist?"
set defaultText to "Suzuki maniac"
set playlistTitle to the text returned of ¬
(display dialog introText default answer defaultText)
return playlistTitle
end getPlaylistTitle

on getIterations(defaultCount)
set defaultText to "How many times should each piece play?"
set iterationCount to the text returned of ¬
(display dialog defaultText default answer defaultCount)
return iterationCount as number
end getIterations

on getArrangement()
set introText to "Arrange the pieces"
set btns to {"Sequentially", "Alternating"}
set returnedItems to display dialog introText buttons btns
return button returned of returnedItems
end getArrangement

We use this to build Suzuki listening playlists.