Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!


Click here to return to the 'Additional script available from Apple' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Additional script available from Apple
Authored by: chaseter on Sep 30, '04 05:25:28PM

I found this script that comes bundled with the iPod scripts on the Apple site (http://www.apple.com/applescript/ipod/). Thought some of you might find it helpful...you could have this script launch with a keystroke as well. It is especially useful if you have two iPods. For instance, I have one 2G iPod as a firewire drive and my 3G for myMP3s and it would eject both upon the initiation of the script :)

Chase

begin applescript--->


try
display dialog "Eject iPod" & return & return & "This scirpt will attempt to eject the currently mounted iPod." buttons {"Cancel", "Continue"} default button 2

-- check for iPods
set the mounted_iPods to my locate_iPods()
-- check for iPod count
if the mounted_iPods is {} then
error "No iPod is connected to this computer."
else if the (count of the mounted_iPods) is greater than 1 then
-- choose iPod
set the ipod_names to {}
repeat with i from 1 to the count of the mounted_iPods
set this_iPod to item i of the mounted_iPods
tell application "Finder"
set the end of the ipod_names to the name of this_iPod
end tell
end repeat
set this_name to (choose from list ipod_names with prompt "Pick the iPod to use:") as string
if this_name is "false" then error number -128
repeat with i from 1 to the count of the ipod_names
if item i of the ipod_names is this_name then
set this_iPod to item i of the mounted_iPods
exit repeat
end if
end repeat
else
set this_iPod to item 1 of the mounted_iPods
end if

tell application "Finder"
eject this_iPod
end tell

display dialog "The iPod has been ejected." buttons {"•"} default button 1 giving up after 2
on error error_message number the error_number
if the error_number is not -128 then
display dialog error_message buttons {"OK"} default button 1
end if
end try

on locate_iPods()
set the volumes_directory to "/Volumes/" as POSIX file as alias
set the volume_names to list folder volumes_directory without invisibles
set mounted_iPods to {}
repeat with i from 1 to the count of volume_names
try
set this_name to item i of volume_names
set this_disk to ("/Volumes/" & this_name & "/") as POSIX file as alias
set these_items to list folder this_disk
if "iPod_Control" is in these_items then
set the end of the mounted_iPods to this_disk
end if
end try
end repeat
return mounted_iPods
end locate_iPods

<-- end applescript



[ Reply to This | # ]
Additional script available from Apple
Authored by: DougAdams on Oct 01, '04 08:13:04AM

This script is pretty much just a fancy version of the little one being discussed. AppleScripts from Apple have to account for many situations (to keep the support calls to a minimum, no doubt). This script will account for more than one iPod being mounted and get the correct name of the iPod, but in the end, it still just ejects the iPod like any other disk.



[ Reply to This | # ]