dougscripts.com

February 17 2016 - 7:24 am

Name New Playlist From Selection

(This a repost from October 25, 2011. The previous post reminded me of it.)

I use the iTunes File > New > Playlist from Selection command a lot to create temporary playlists. Actually, I use the Shift-Command-N shortcut more often than clicking the command in the File menu. But I'm irritated at all the dancing I have to do to name the new "untitled playlist". It takes my attention away from what I was intending to do with the tracks. So, I rigged the script below to the keyboard shortcut Shift-Command-N—and, luckily, it works. Sometimes assigning a shortcut that iTunes is already using doesn't override the original command. The script does exactly what "Playlist from Selection" does except now I can enter the name for the playlist before it's created.

Here's the script:

tell application id "com.apple.iTunes"

try

set sel to selection

set theSource to container of view of front browser window

if sel is {} then error

set opt to (display dialog ¬

"Make new playlist from selected tracks named:" default answer ¬

"" with title "Name New Playlist From Selection" with icon 1)

set newName to (text returned of opt)

if newName is "" then error

on error

return

end try

set newPlaylist to (make new playlist at theSource with properties {name:newName})

repeat with t in sel

try

duplicate t to newPlaylist

end try

end repeat

reveal newPlaylist

end tell

I named it "Name New Playlist from Selection", saved it to ~/Library/iTunes/Scripts/ and gave it the shortcut using these instructions.

Site contents © 2001 - 2024 (that's right: 2001) Doug Adams and weblished by Doug Adams. Contact support AT dougscripts DOT com. About.
All rights reserved. Privacy.
AppleScript, iTunes, iPod, iPad, and iPhone are registered trademarks of Apple Inc. This site has no direct affiliation with Apple, Inc.
The one who says "it cannot be done" should not be interrupting the one who is doing it.