Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

wrignj08

macrumors newbie
Original poster
Jun 13, 2009
28
0
Hey all
Could somebody help me out? on my carputer i would like to have an applescript that would collect songs from a specific folder on a usb flash drive and copy them to iTunes. So when I get some new songs on my home mac i can load them on to the flash drive, Then plug the drive in to my carputer start the apple script and import all the new songs. (I wish it to be done by applescript so it appears "seamless".)

Thanks
 
Ok so i worked out how to do it :),

First you will want to create a folder on your desktop of the destination mac called "new music". Then attach the following script to "new music" via the "Attach a Folder Action" contextual menu option.
This folder action will copy media placed in the "new music" folder to iTunes and then delete the original from "new music".


(taken from "http://dougscripts.com/itunes/itinfo/folderaction01.php")

*****************************************************
Code:
on adding folder items to my_folder after receiving the_files
	repeat with i from 1 to number of items in the_files
		tell application "iTunes"
			launch
			try
				set this_file to (item i of the_files)
				
				add this_file
				
				-- if you have iTunes set to 
				--"Copy files to iTunes Music folder when adding to library"
				-- then you might want to delete the original file...
				-- if so, remove comments from this block and 
				-- use the UNIX commands below to delete the file
				
				set the file_path to the quoted form of the POSIX path of this_file
				do shell script ("rm -f " & file_path)
				
			end try
		end tell
	end repeat
end adding folder items to
*****************************************************

Then you need a script that will copy the songs to the "new music" folder from a usb stick.

*****************************************************
Code:
tell application "Finder"
	set a to folder "USB Music:Music"
	set b to folder "Macintosh HD:Users:"My Name":Desktop:new music"
	move every file of a to b
end tell
*****************************************************


Ok now when you run the second script the songs will move from "USB Music/Music" to "new music", which will then be added to iTunes and then deleted from the "new music" folder.


Hope that help some one in the future
 
Last edited by a moderator:
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.