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


Click here to return to the 'Eject nearly any disk via AppleScript' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Eject nearly any disk via AppleScript
Authored by: renaultssoftware on Apr 04, '10 04:37:05PM
I know. Something's wrong with it. So I'll add the new code below.
on run
	tell application "System Events"
		set diskNames to the name of every disk whose ejectable is true
		set diskCount to count diskNames
		if diskCount = 0 then
			beep
		else if diskCount = 1 then
			try
				if item 1 of diskNames does not contain "Time Machine" then
					tell application "Finder"
						eject item 1 of diskNames
					end tell
				end if
			on error
				beep
			end try
		else if diskCount ≥ 2 then
			set newDiskNames to choose from list diskNames with prompt "Choose disks to eject:" with title "Eject Media" OK button name "Eject" with multiple selections allowed
			set newDiskCount to count newDiskNames
			if newDiskCount = 0 then
				beep
			else if newDiskCount = 1 then
				try
					if item 1 of newDiskNames does not contain "Time Machine" then
						tell application "Finder"
							eject item 1 of newDiskNames
						end tell
					end if
				on error
					beep
				end try
			else if newDiskCount ≥ 2 then
				repeat with thisDisk in newDiskNames
					try
						if thisDisk does not contain "Time machine" then
							tell application "Finder"
								eject thisDisk
							end tell
						end if
					on error
						beep
					end try
				end repeat
			end if
		end if
	end tell
end run
on open theDisk
	repeat with thisDisk in theDisk
		try
			tell application "Finder"
				eject thisDisk
			end tell
		on error
			beep
		end try
	end repeat
end open


[ Reply to This | # ]