Copying music files of specific playlist to a thumb drive
#1
Posted 12 May 2012 - 01:39 PM
I have a playlist with songs rated from 4 to 5 stars. I want to be able to copy only those songs (and their respective parent-folders) from my iTunes Music folder to a folder on a thumb drive, so that I can use that with my car stereo system. Is that possible with iTunes? Or is that a task for the AppleScript? If the latter, can someone help with the script (path to my Music folder is: /Volumes/ARCHIVE 2/MASTERING/MUSIC/• iTUNES (MP3)/iTunes Media/Music)?
#2
Posted 13 May 2012 - 01:55 AM
rovertek, on 12 May 2012 - 01:39 PM, said:
I have a playlist with songs rated from 4 to 5 stars. I want to be able to copy only those songs (and their respective parent-folders) from my iTunes Music folder to a folder on a thumb drive, so that I can use that with my car stereo system. Is that possible with iTunes? Or is that a task for the AppleScript? If the latter, can someone help with the script (path to my Music folder is: /Volumes/ARCHIVE 2/MASTERING/MUSIC/• iTUNES (MP3)/iTunes Media/Music)?
Without the requirement to copy the folders, this is just a simple matter of drag-and-drop from iTunes to Finder. This should work. Replace the string "Source Playlist" (retaining the quotes) with the name of your playlist.
property theRoot : POSIX file "/Volumes/ARCHIVE 2/MASTERING/MUSIC/• iTUNES (MP3)/iTunes Media/Music" as alias
tell application "iTunes"
set theTrackList to location of every file track of playlist "Source Playlist"
end tell
tell application "Finder"
repeat with theTrackAlias in theTrackList
set theAlbumAlias to container of theTrackAlias
set theArtistAlias to container of theAlbumAlias
set theAlbumName to name of theAlbumAlias
set theArtistName to name of theArtistAlias
try
set theArtistFolder to folder theArtistName of theRoot
on error
set theArtistFolder to make new folder at theRoot with properties {name:theArtistName}
end try
try
set theAlbumFolder to folder theAlbumName of theArtistFolder
on error
set theAlbumFolder to make new folder at theArtistFolder with properties {name:theAlbumName}
end try
duplicate theTrackAlias to theAlbumFolder
end repeat
end tell
This post has been edited by bastion: 13 May 2012 - 01:58 AM
#3
Posted 13 May 2012 - 04:56 PM
#4
Posted 14 May 2012 - 02:23 AM
rovertek, on 13 May 2012 - 04:56 PM, said:
I just noticed that the path you gave was to your music folder. You should replace that string in the first line with the path to the folder on the thumb drive were you want the files copied.
#5
Posted 14 May 2012 - 01:14 PM
bastion, on 14 May 2012 - 02:23 AM, said:
Hi, bastion,
Yeah, I noticed that. I tried the script with the corrected path, but it returned the error. I'm guessing that the error occurred in the line containing the blue cursor in the attached screenshot, but I am not sure. What do you think? Is it possible that the space in the name of my playlist may be a problem?
http://img12.imagesh...ptwitherror.png
#6
Posted 14 May 2012 - 05:12 PM
rovertek, on 14 May 2012 - 01:14 PM, said:
bastion, on 14 May 2012 - 02:23 AM, said:
Hi, bastion,
Yeah, I noticed that. I tried the script with the corrected path, but it returned the error. I'm guessing that the error occurred in the line containing the blue cursor in the attached screenshot, but I am not sure. What do you think? Is it possible that the space in the name of my playlist may be a problem?
The space in the playlist name isn't a problem. When I was writing it, the playlist I used to test had a space in the name.
From poking around a little online, it seems likely that the problem is that AppleScript isn't especially tolerant of leading spaces on lines of the script, and it looks like the MacWorld forum software converted the script's indenting to spaces. Try getting rid of all the leading space and see if that sorts it out.
#7
Posted 15 May 2012 - 05:32 PM
bastion, on 14 May 2012 - 05:12 PM, said:
The space in the playlist name isn't a problem. When I was writing it, the playlist I used to test had a space in the name.
From poking around a little online, it seems likely that the problem is that AppleScript isn't especially tolerant of leading spaces on lines of the script, and it looks like the MacWorld forum software converted the script's indenting to spaces. Try getting rid of all the leading space and see if that sorts it out.
Works like a charm! You were right. After I got rid of leading spaces, script worked as expected. Thanks again, bastion.
I have always wished I'd learn AppleScript, but for a non-technical guy like me, that's a tall order. Considering the very sporadic use for me, AppleScript will probably continue to exist only on my wish-list. Thank heavens for guys like you!
Help











