PDA

View Full Version : Applescript USB flash drive to iTunes?




wrignj08
Jun 23, 2011, 05:42 AM
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



wrignj08
Jun 23, 2011, 07:51 AM
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")

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

*****************************************************
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