Prev: Airport Express alternative?
Next: A haaaannnndbag?
From: Steve Hodgson on 19 Apr 2010 17:56 I'm using an Applescript to unmount my local USB drives but get a dialog when I run it because one drive is partitioned into two. The message asks if I want to eject all partitions or just one. Can anyone think of a way to remove or disable the prompt? Cheers, Steve tell application "Finder" set local_disks to every disk whose local volume is true repeat with local_disk in local_disks eject local_disk end repeat -- Give the drives time to unmount. Optical discs can take awhile. delay 2 -- The boot volume is always there and can never be ejected, so when all local drives are ejected, there will still be one remaining if (count of (every disk whose local volume is true)) is not 1 then error "Could not unmount all local drives" end if end tell -- Cheers, Steve The reply-to email address is a spam trap. Email steve 'at' shodgson 'dot' org 'dot' uk
From: Bruce Horrocks on 19 Apr 2010 20:00 On 19/04/2010 22:56, Steve Hodgson wrote: > I'm using an Applescript to unmount my local USB drives but get a dialog > when I run it because one drive is partitioned into two. The message > asks if I want to eject all partitions or just one. > > Can anyone think of a way to remove or disable the prompt? eject takes a list as a parameter so you could try ejecting all in one command, viz: tell application "Finder" to eject (every disk whose local volume is true) Or better might be: tell application "Finder" to eject (every disk whose ejectable is true) -- Bruce Horrocks Surrey England (bruce at scorecrow dot com)
From: Bruce Horrocks on 20 Apr 2010 15:39 On 20/04/2010 12:39, Steve wrote: > On Apr 20, 1:00 am, Bruce Horrocks<07....(a)scorecrow.com> wrote: >> On 19/04/2010 22:56, Steve Hodgson wrote: >> >>> I'm using an Applescript to unmount my local USB drives but get a dialog >>> when I run it because one drive is partitioned into two. The message >>> asks if I want to eject all partitions or just one. >> >>> Can anyone think of a way to remove or disable the prompt? >> >> eject takes a list as a parameter so you could try ejecting all in one >> command, viz: >> >> tell application "Finder" to eject (every disk whose local volume is true) >> >> Or better might be: >> tell application "Finder" to eject (every disk whose ejectable is true) > > Would that not still create the dialogue when it hits the first > partitioned drive in the list? Pass because I'm away from home at the moment and don't have a suitable drive to test it on. I'm hoping that the Finder has enough sense to realise that the volumes in the list are all on the same physical drive and therefore it has no need to query the user about ejecting a disk where a volume is still in use. I can test it at the weekend and let you know. > I tried a menu bar application called 'Ejector' last night and that > did eject all drives with no dialogues so I suspect this will be > possible. Ejector was no use as it ejects ALL drives including iDisks. You really want a script, I assume, so that you can hard code the names of your volumes and so not have to worry about CDs being ejected etc. -- Bruce Horrocks Surrey England (bruce at scorecrow dot com)
From: Bruce Horrocks on 24 Apr 2010 10:03 On 20/04/2010 12:39, Steve wrote: > On Apr 20, 1:00 am, Bruce Horrocks<07....(a)scorecrow.com> wrote: >> On 19/04/2010 22:56, Steve Hodgson wrote: >> >>> I'm using an Applescript to unmount my local USB drives but get a dialog >>> when I run it because one drive is partitioned into two. The message >>> asks if I want to eject all partitions or just one. >> >>> Can anyone think of a way to remove or disable the prompt? >> >> eject takes a list as a parameter so you could try ejecting all in one >> command, viz: >> >> tell application "Finder" to eject (every disk whose local volume is true) >> >> Or better might be: >> tell application "Finder" to eject (every disk whose ejectable is true) > > Would that not still create the dialogue when it hits the first > partitioned drive in the list? > > I tried a menu bar application called 'Ejector' last night and that > did eject all drives with no dialogues so I suspect this will be > possible. Ejector was no use as it ejects ALL drives including iDisks. Okay, now I'm back, I experimented with a FireWire [1] drive that is partitioned into 2, named "Drive 1" and "Drive 2". This is under SL 10.6.3 If I eject either from a Finder window then a dialog pops up telling me that it is one of a pair and gives me the option to eject all or cancel etc. If I run the following AppleScript tell application "Finder" to eject "Drive 1" then it *unmounts* the drive without any dialog, but doesn't actually eject it. That is, the drive light stays on and Disk Utility sees it as unmounted but not ejected. Similarly tell application "Finder" to eject {"Drive 1", "Drive 2"} unmounts both drives but still fails to eject as far as Disk Utility is concerned. So I'm not quite sure why you get a message while I don't when using AppleScript unless you are on an earlier version of MacOSX? Regards, [1] but that should not make a different -- Bruce Horrocks Surrey England (bruce at scorecrow dot com)
From: Bruce Horrocks on 24 Apr 2010 11:18
On 24/04/2010 15:29, Colin Harper wrote: > On Sat, 24 Apr 2010 15:03:08 +0100, Bruce Horrocks wrote > (in article<83gc0sFu3fU1(a)mid.individual.net>): > >> On 20/04/2010 12:39, Steve wrote: >>> On Apr 20, 1:00 am, Bruce Horrocks<07....(a)scorecrow.com> wrote: >>>> On 19/04/2010 22:56, Steve Hodgson wrote: >>>> >>>>> I'm using an Applescript to unmount my local USB drives but get a dialog >>>>> when I run it because one drive is partitioned into two. The message >>>>> asks if I want to eject all partitions or just one. >>>> >>>>> Can anyone think of a way to remove or disable the prompt? >>>> >>>> eject takes a list as a parameter so you could try ejecting all in one >>>> command, viz: >>>> >>>> tell application "Finder" to eject (every disk whose local volume is true) >>>> >>>> Or better might be: >>>> tell application "Finder" to eject (every disk whose ejectable is true) >>> >>> Would that not still create the dialogue when it hits the first >>> partitioned drive in the list? >>> >>> I tried a menu bar application called 'Ejector' last night and that >>> did eject all drives with no dialogues so I suspect this will be >>> possible. Ejector was no use as it ejects ALL drives including iDisks. >> >> Okay, now I'm back, I experimented with a FireWire [1] drive that is >> partitioned into 2, named "Drive 1" and "Drive 2". This is under SL 10.6.3 >> >> If I eject either from a Finder window then a dialog pops up telling me >> that it is one of a pair and gives me the option to eject all or cancel etc. >> >> If I run the following AppleScript >> >> tell application "Finder" to eject "Drive 1" >> >> then it *unmounts* the drive without any dialog, but doesn't actually >> eject it. That is, the drive light stays on and Disk Utility sees it as >> unmounted but not ejected. >> >> Similarly >> >> tell application "Finder" to eject {"Drive 1", "Drive 2"} >> >> unmounts both drives but still fails to eject as far as Disk Utility is >> concerned. >> > > > Why don't you script diskutil to do this kind of work? It's what I use. Perhaps you could post your code then, showing the OP how to find and pass the right volume info to diskutil. -- Bruce Horrocks Surrey England (bruce at scorecrow dot com) |