Skip navigation

MERGING two Scripts to Unmount disks except booting disk

1159 Views 6 Replies Latest reply: Jun 14, 2013 2:56 PM by ApMaX RSS
ApMaX Level 1 Level 1 (5 points)
Currently Being Moderated
Jun 14, 2013 3:47 AM

How to merge this AppleScript:



set volname to "MemoryFlashCard" -- # name of target volume 

set p to (POSIX path of (volname & ":" as alias))'s text 1 thru -2

set sh to "diskutil umount " & quoted form of p & " &> /dev/null &"

do shell script sh



that unmounts Memory Flash Cards like the

SanDisk Extreme 128 GB SDXC Class 10 UHS-1 Flash Memory Card 45MB/s SDSDX-128G-X46


with this AppleScript that unmounts the internal Macintosh HD:



set volname to "Macintosh HD" -- # name of target volume 

set p to (POSIX path of (volname & ":" as alias))'s text 1 thru -2

set sh to "diskutil umount " & quoted form of p & " &> /dev/null &"

do shell script sh



so that the MemoryFlashCard is unmounted FIRST, and then the Macintosh HD after rebooting or cold booting the Mac from an external disk?



  • Phil Stokes Level 2 Level 2 (325 points)

    I'm not being funny, but having followed a number of your posts and threads on this issue, I have to say it does seem like you're not trying to solve a particular problem you're having, but rather exploiting the knowledge of this forum's users to develop and distribute an App to others that will do something which you don't have any understanding yourself of how to do.


    I might be wrong, I probably am, and I hope I am, but in case I'm not let me point out this:


    this is a forum for troubleshooting problems, answered by fellow amateur enthusiasts, and not a free 'develop my app for me' service.

  • Mark Jalbert Level 5 Level 5 (4,385 points)

    Make your variable names unique in each code block and your script should run without any problems; or you could create a list of each device name and loop thru the list in one code block.

  • Hiroto Level 5 Level 5 (4,810 points)



    The AppleScript script below will unmount every device node which is mounted at mount point in /Volumes. Not sure whether it is safe with RAID.


    do shell script "for dev in $(mount | perl -lne 'print $1 if m%(^/dev/[^[:space:]]+) on /Volumes/.*%o')
         diskutil unmount $dev >/dev/null 2>&1 &





More Like This

  • Retrieving data ...

Bookmarked By (0)


  • This solved my question - 10 points
  • This helped me - 5 points
This site contains user submitted content, comments and opinions and is for informational purposes only. Apple disclaims any and all liability for the acts, omissions and conduct of any third parties in connection with or related to your use of the site. All postings and use of the content on this site are subject to the Apple Support Communities Terms of Use.