Macworld Forums

Macworld Forums: Copying music files of specific playlist to a thumb drive - Macworld Forums

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Copying music files of specific playlist to a thumb drive

#1 User is offline   rovertek 

  • Member
  • PipPip
  • Group: Members
  • Posts: 66
  • Joined: 19-May 11

Posted 12 May 2012 - 01:39 PM

Can someone, please, help me with this iTunes task:

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)?
0

#2 User is offline   bastion 

  • Power User
  • PipPipPipPip
  • Group: Members
  • Posts: 9,272
  • Joined: 14-October 04

Posted 13 May 2012 - 01:55 AM

View Postrovertek, on 12 May 2012 - 01:39 PM, said:

Can someone, please, help me with this iTunes task:

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

0

#3 User is offline   rovertek 

  • Member
  • PipPip
  • Group: Members
  • Posts: 66
  • Joined: 19-May 11

Posted 13 May 2012 - 04:56 PM

Thanks, bastion, I did not expect such a prompt reply... I will certainly give this script a try. Much obliged!
0

#4 User is offline   bastion 

  • Power User
  • PipPipPipPip
  • Group: Members
  • Posts: 9,272
  • Joined: 14-October 04

Posted 14 May 2012 - 02:23 AM

View Postrovertek, on 13 May 2012 - 04:56 PM, said:

Thanks, bastion, I did not expect such a prompt reply... I will certainly give this script a try. Much obliged!


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.
0

#5 User is offline   rovertek 

  • Member
  • PipPip
  • Group: Members
  • Posts: 66
  • Joined: 19-May 11

Posted 14 May 2012 - 01:14 PM

View Postbastion, on 14 May 2012 - 02:23 AM, said:

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.

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
0

#6 User is offline   bastion 

  • Power User
  • PipPipPipPip
  • Group: Members
  • Posts: 9,272
  • Joined: 14-October 04

Posted 14 May 2012 - 05:12 PM

View Postrovertek, on 14 May 2012 - 01:14 PM, said:

View Postbastion, on 14 May 2012 - 02:23 AM, said:

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.

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.
0

#7 User is offline   rovertek 

  • Member
  • PipPip
  • Group: Members
  • Posts: 66
  • Joined: 19-May 11

Posted 15 May 2012 - 05:32 PM

View Postbastion, 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! :)
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users