Skip to content

Instantly share code, notes, and snippets.

@GWillmann
Created January 22, 2017 19:57
Show Gist options
  • Save GWillmann/b5754f52c4bb7c0a29bd78a315d4ff41 to your computer and use it in GitHub Desktop.
Save GWillmann/b5754f52c4bb7c0a29bd78a315d4ff41 to your computer and use it in GitHub Desktop.
Copy all songs from an iTunes playlist to a folder (e.g.: a usb disk)
tell application "iTunes"
-- Asks the user to select a playlist to copy
set itunesPlaylists to (get name of playlists)
set selectedPlaylist to {choose from list itunesPlaylists}
-- Get every track in the selected playlist
set itunesFiles to (every file track of playlist (item 1 of (item 1 of selectedPlaylist)))
-- Asks the user to select the destination folder (where the files will be copied)
set destinationPath to (choose folder with prompt "Destination folder :")
-- Creates a list of the files' path
set pathsList to {}
repeat with iTunesFile in itunesFiles
set loc to (get location of iTunesFile as text)
set pathsList to pathsList & {loc}
end repeat
-- Copies the files into the destination folder
repeat with finderPath in pathsList
my duplicateSong(finderPath, destinationPath)
end repeat
end tell
-- Copies iTunesFile into destination folder
on duplicateSong(iTunesFile, destination)
tell application "Finder"
set n to destination as alias
duplicate iTunesFile to n
end tell
end duplicateSong
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment