• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: disconnect external volumes
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: disconnect external volumes


  • Subject: Re: disconnect external volumes
  • From: Matt Ray <email@hidden>
  • Date: Mon, 15 Apr 2002 14:26:16 -0500

Thanks Chris.

This is what I have found to work best:

tell application "Finder"
eject (every disk whose ejectable is true)
delete (every disk whose local volume is false)
end Tell

The only problem is that this is part of a longer desktop rebuild script that is in the shutdown folder and if someone has placed a file from a remote volume in their trash and then shutsdown an error dialog comes up.

I don't want to empty everything in their trash incase they have local files in their trash. Can't use the try wrapper because if the volume is not disconnected then an error will come up later in the script.

If I disable this shutdown script and have a remote volume mounted and a file from that remote volume in my trash the computer will automatically delete the remote file from the trash without any errors.

My question is on shutdown how does it automatically delete only that remote file and more importantly how could I have AS do it.

TIA,
Matt Ray

Here is the script I'm using in it's entirety here:

tell application "Finder"
eject (every disk whose ejectable is true)
delete (every disk whose local volume is false)
set Today to (current date)
set LastWeek to (Today - (((60 * 60) * 24) * 7))
set ListDisk to every disk whose ejectable is false
repeat with i from 1 to (count items in ListDisk)
set DiskName to name of item i of ListDisk
set FileVisible1 to DiskName & ":Desktop DB"
set FileVisible2 to DiskName & ":Desktop DF"
make file visible of alias FileVisible1
make file visible of alias FileVisible2
set DateFile1 to (creation date) of alias FileVisible1
set DateFile2 to (creation date) of alias FileVisible2
if DateFile1 < LastWeek then
delete alias FileVisible1
else
make file invisible of alias FileVisible1
end if
if DateFile2 < LastWeek then
delete alias FileVisible2
else
make file invisible of alias FileVisible2
end if
end repeat
end tell



On Friday, April 12, 2002, at 11:34 AM, JJ wrote:

When the "list disks" command is used you get a list of your hardrive
name along with any disks that you have mounted including any servers
that you are connected to through a network.

Is there a way via AS to dismount or disconnect from all of these
except for your hardrive?

Usually, your startup disk has ID -1 (ask the Finder about IDs).

Alternatively, you could use the various properties of disks in the Finder to determine which ones you want, in particular "local volume", "ejectable", and "startup". For example:

tell application "Finder"
eject every disk whose startup is false
-- eject everything but the startup disk

eject every disk whose local volume is false
-- "eject" every non-local disk, i.e., all server volumes.
end

These two are quite different, especially if you have multiple hard drives or partitions.


--Chris Nebel
AppleScript Engineering
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.

References: 
 >Re: disconnect external volumes (From: Christopher Nebel <email@hidden>)

  • Prev by Date: Re: Stuffit Expander
  • Next by Date: Re: script speed
  • Previous by thread: Re: disconnect external volumes
  • Next by thread: "set name" not working - newbie question -urgent
  • Index(es):
    • Date
    • Thread