• 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
Considerable simplification should be possible
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Considerable simplification should be possible


  • Subject: Considerable simplification should be possible
  • From: Lists <email@hidden>
  • Date: Sun, 27 Apr 2014 22:54:33 -0700

My iMac usually has 4 to 6 external hard drives attached but unmounted (so that a bunch of drives don't have to wake up each time some app puts up an open and save dialog). Every time I need to access one of these unmounted drives, I open Disk Utility, select the drive and click the mount button. Works every time but involves several steps, so I decided to automate the process.

I have a working script that I think is making too many shell calls and I would like to simplify. In particular the first shell call could get the disk identifiers (for example "disk0s2") as well as the volume names. I tried building two lists from the first shell call, but couldn't figure out how to associate the second list after the "choose from list"  part of the script.

The script that follows presents me with a list of attached hard drives from which I can choose a drive to mount, and mounts it after choosing. As I said, I think it could be simpler.

set theVolumeNamesList to {}
set HFSdiskList to do shell script "diskutil list | grep Apple_HFS"
set x to paragraphs of HFSdiskList
repeat with LVar in items of x
set thisVolumeName to word 3 of LVar
set the end of theVolumeNamesList to thisVolumeName
end repeat
set volumeChoice to (choose from list theVolumeNamesList with prompt "Choose a volume to mount.")
if the result is not false then
set volumeToMount to volumeChoice
set shellScpt to "diskutil list | grep " & volumeToMount & ""
set whatItem to (do shell script shellScpt) --the disk identifier is the last word of what's returned here
do shell script "diskutil mount " & (last word of whatItem)
end if

Thanks
J

 _______________________________________________
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

  • Follow-Ups:
    • Re: Considerable simplification should be possible
      • From: "koenig.yvan" <email@hidden>
  • Prev by Date: Re: XMLlib library
  • Next by Date: Re: Considerable simplification should be possible
  • Previous by thread: Re: System info
  • Next by thread: Re: Considerable simplification should be possible
  • Index(es):
    • Date
    • Thread