Name New Playlist From Selection, Updated
I've mentioned my "Name New Playlist From Selection" script in the past. It emulates iTunes' "Playlist From Selection" command with the added feature of asking for the playlist name before actually creating the playlist. This just seems to make sense to me rather than naming it afterwards. I've given it the same keyboard shortcut as the iTunes command (Shift-Command-N) so that the script is launched instead of the command being carried out.
Here is an updated version of that script which adds an option to provide a playlist description. The default text presented will be "Created 4/4/2018", or whatever the current date is.
(In case you don't know, the "¬" character is used to break up a single line of code for easier display; it is ignored by the AppleScript compiler.)
property myTitle : "Name New Playlist From Selection"
tell application "iTunes"
try
set theSelection to selection of front browser window
set theSource to container of view of front browser window
if theSelection is {} then error
set newName to text returned of (display dialog ¬
"Make new playlist from selected tracks named:" default answer ¬
"" with title myTitle with icon 1)
if newName is "" then error
on error
return
end try
set myDescription to ""
try
set ddResult to (display dialog ¬
"Add description?" default answer my makeCurrentDate() buttons ¬
{"No", "Yes"} default button 2 with title myTitle with icon 1)
if button returned of ddResult is "yes" then
set myDescription to text returned of ddResult
end if
end try
set newPlaylist to (make new playlist at theSource with properties ¬
{name:newName, description:myDescription})
repeat with aTrack in theSelection
try
duplicate aTrack to newPlaylist
end try
end repeat
reveal newPlaylist
end tell
to makeCurrentDate()
return ("Created " & short date string of (get current date)) as text
end makeCurrentDate
Open this in Script Editor by clicking the little little script icon above. Save it named whatever you like with the Format "Script" (.scpt) in your ~/Library/iTunes/Scripts/ folder so that it will be listed in the iTunes Script menu. Follow the instructions on this page to add a keyboard shortcut.
To use: select some tracks in iTunes and launch the script. It will ask you to enter a name for the new playlist and then whether or not to provide a description. The tracks you selected will be copied to a newly created playlist with the name you provided—and description, if you entered one.