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


Click here to return to the 'An AppleScript to mount, run, unmount a disk image' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
An AppleScript to mount, run, unmount a disk image
Authored by: Christian Leue on Sep 08, '04 01:27:24AM
I achieve basically the same results with the following code:


on idle
	tell application "Finder" to eject "Zoo Tycoon"
	tell application "Finder" to eject "Marine Mania"
	quit
end idle

on run
	set myPath to trim_line((path to me as string), "Zoo Tycoon start.app", 1)
	do shell script ("hdiutil mount \"" & POSIX path of (myPath as string) & "Zoo Tycoon.dmg\"")
	do shell script ("hdiutil mount \"" & POSIX path of (myPath as string) & "Marine Mania.dmg\"")
	set myApp to myPath & "Zoo Tycoon"
	tell application myApp to activate
	idle
end run


on trim_line(this_text, trim_chars, trim_indicator)
	-- 0 = beginning, 1 = end, 2 = both
	set x to the length of the trim_chars
	-- TRIM BEGINNING
	if the trim_indicator is in {0, 2} then
		repeat while this_text begins with the trim_chars
			try
				set this_text to characters (x + 1) thru -1 of this_text as string
			on error
				-- the text contains nothing but the trim characters
				return ""
			end try
		end repeat
	end if
	-- TRIM ENDING
	if the trim_indicator is in {1, 2} then
		repeat while this_text ends with the trim_chars
			try
				set this_text to characters 1 thru -(x + 1) of this_text as string
			on error
				-- the text contains nothing but the trim characters
				return ""
			end try
		end repeat
	end if
	return this_text
end trim_line



[ Reply to This | # ]
An AppleScript to mount, run, unmount a disk image
Authored by: rhithyn on Sep 08, '04 10:03:55AM

One problem:

This will only eject disks that are visible in the desktop view. I have set the name of my mail volume to ".Mail" to keep it off of my desktop, but still have all other mounted images show up. Whenever I try to eject the volume using Finder's "eject" command, it says it can't find the volume, although it is in the disk list.

Any ideas on how to make the finder eject hidden volumes?



[ Reply to This | # ]
An AppleScript to mount, run, unmount a disk image
Authored by: emendelson on Sep 08, '04 02:45:56PM

The script at the top of this story (the original hint) ejects hidden disks because it doesn't use the finder to mount or unmount them - it uses shell scripts.



[ Reply to This | # ]
An AppleScript to mount, run, unmount a disk image
Authored by: rhithyn on Sep 08, '04 07:51:00PM

I should have clarified that I was commenting on Christian Leue's script and not on the original script. Sorry!



[ Reply to This | # ]