Just starting with OS X and AppleScript. It seems that AS is different from OS 9. I had a small script that unmounted my active volumes/disks, and it doesn’t work anymore. I read as:
tell application “Finder”
select disks of desktop as list
set listededisques to selection
repeat with i from 1 to count of listededisques
if item i of listededisques is not the startup disk then
unmount item i of listededisques
end if
end repeat
end tell
I tried to change “unmount” with “put away” and it doesn’t work neither. I tried to look up the FINDER dictionnary to see the “put away” command is not there ?? So I tried to locate the STANDARD ADDITION dictionnary, and was asked to locate STANDARD ADDITION. I found it it the SCRIPTING ADDITION of my hard disk but was not able to select it … I need a little help !!!':rolleyes:
tell application "Finder"
try
eject (disks of desktop whose startup is false)
on error e
display dialog e buttons ¬
{"OK"} default button 1 with icon 1
end try
end tell
Like you, I only have one external hard disk, but with 2 mounted volume. I want either to unmount the drive or the 2 volume. The script did not produce any dialog … ??? Thanks
I can confirm that Rob’s script works on my machine too. (OS 10.2.8.) Possibly the reason you’re not getting an error message is that ‘eject’ doesn’t give one. This simply does nothing on my machine:
tell application "Finder" to eject startup disk
In fact, all that’s needed to eject any ejectable disk and leave the rest is:
tell application "Finder" to eject disks
(In OS 9, you could just tell the Finder to ‘eject’, without a parameter.)
You could try telling the Finder to update the desktop after the ejection.
It’s also worth checking that your disk/partitions are actually ejectable in OS X. (Mine are in X, but not in OS 9!)
tell application "Finder"
get ejectable of disks whose startup is false
end tell
If the result is {false, false}, that would explain the problem. You may need to upgrade your external disk’s driver, if an OS X compatible version is available. You can often download upgrades from manufacturer’s Web sites.
The code “tell application “Finder” to eject disks” worked. Thanks. Thank you both for trying.
What I am trying to do is:
mount the connected but unmounted external drive and wait;
open RETROSPECT and execute a script
wait until RETROSPECT is finished
unmount the drive
What is the command to mount a drive ? (“Mount” does not seem to work) and to have the script pause until RETROSPECT is finished ?? Thanks for your help.
I’m glad ‘tell application “Finder” to eject disks’ worked, though it’s strange that it did when Rob’s script didn’t. I can only assume that the Finder wasn’t fully updated with regard to your disks’ properties and that the returned value of their ‘startup’ properties was something like ‘missing value’. Since Rob’s script specifically mentioned disks whose startup was ‘false’, your disks wouldn’t have been included. It’s a fairly common problem with the OS X Finder that it has be told to ask other parts of the system for information using the ‘update’ command. Something like this might work:
tell application "Finder"
update disks
eject disks whose startup is false
end
I don’t know of any way to remount an ejected local disk except by reinserting it into the drive (or plugging the drive back into the computer if it’s a FireWire or USB device), logging out and logging in again, or restarting the computer. Possibly there’s some Unix command or an OSAX that can do it. (If you were using ‘mount’ and/or ‘unmount’ in your OS 9 script, you’d have been using a third-party OSAX. The Finder has never had these commands.)
I’ve never scripted Retrospect for myself. The Retrospect Express I use on my OS 9/OS X disk isn’t scriptable, but the following seems to work with the old, full version on my OS 8.6 machine. You might find something better or more up-to-date in your own version’s dictionary:
tell application "Retrospect"
activate
execute "AppleScript Test" type Full -- forced full update with a Retrospect script
repeat while executing of (Retrospect status)
delay 5
end repeat
end tell
delay 5 -- extra delay for good luck
beep 5 -- beeps after Retrospect has automatically quit