• 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: Eject image
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Eject image


  • Subject: Re: Eject image
  • From: Christopher Stone <email@hidden>
  • Date: Thu, 28 Feb 2013 13:07:23 -0600

On Feb 28, 2013, at 11:53, Luther Fuller <email@hidden> wrote:
Careful. The name of the image file may NOT be the name of the image disk it mounts.
(The user can change the name of the image file in the Finder.)
______________________________________________________________________

Hey Luther,

Absolutely true.

In fact my test image actually demonstrates this:

~/Downloads/TEST.sparseimage
/Volumes/TEST_Sparse

I just changed the names in the script to demonstrate a normal use-case.

There could also be more than one disk image mounted, so a little more parsing might be necessary:

-------------------------------------------------------------------------------------------

set AppleScript's text item delimiters to "================================================"
set diskImageInfo to text items 2 thru -1 of (do shell script "hdiutil info")

-------------------------------------------------------------------------------------------

From there it's easy to match up an image's path with its name.

Or you could trim it down this way:

-------------------------------------------------------------------------------------------

set diskImageInfo to (do shell script "hdiutil info | sed -En '/^(image-path|\\/dev\\/.+\\/Volumes)/p'")

-------------------------------------------------------------------------------------------

OR to shorten things up

-------------------------------------------------------------------------------------------

set diskImageInfo to (do shell script "hdiutil info | sed -En '/^(image-path|\\/dev\\/.+\\/Volumes)/{
s/.+\\/([^\\/]+$)/\\1/p
}'")
set diskImageInfo to paragraphs of diskImageInfo

set _disks to {}
repeat with i from 1 to length of diskImageInfo by 2
tell diskImageInfo
set end of _disks to {item i, item (i + 1)}
end tell
end repeat

_disks

-------------------------------------------------------------------------------------------

--
Best Regards,
Chris

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users

This email sent to email@hidden

References: 
 >Eject image (From: Robert Poland <email@hidden>)
 >Re: Eject image (From: Christopher Stone <email@hidden>)
 >Re: Eject image (From: Luther Fuller <email@hidden>)

  • Prev by Date: Re: Eject image
  • Next by Date: Re: Eject image
  • Previous by thread: Re: Eject image
  • Next by thread: Re: Eject image
  • Index(es):
    • Date
    • Thread