6 Replies Latest reply: Jun 7, 2012 12:53 PM by mavric1298
mavric1298 Level 1 Level 1 (0 points)

So I can't seem to figure out whats wrong with my script, any help would be greatly appreciated;


So when I run it, it will mount the drive if it is unmounted, but it won't unmount the drive when run


set diskName to "OptiBay"

tell application "Finder"

          if disk diskName exists then

  eject disk diskName


                    tell current application

                              set deviceLine to (do shell script "diskutil list | grep \"" & diskName & "\" | awk '{ print $NF }' ")

                              if deviceLine = "" then

                                        display dialog "The disk \"" & diskName & "\" cannot be found." buttons {"OK"} default button 1 with title "Error" with icon caution

                              end if

                              set foundDisks to paragraphs of deviceLine

                              repeat with i from 1 to number of items in foundDisks

                                        set this_item to item i of foundDisks

                                        if this_item contains "disk" then

                                                  do shell script "diskutil mountDisk /dev/" & this_item

                                        end if

                              end repeat

                    end tell

          end if

end tell

MacBook Pro (15-inch Core 2 Duo), Mac OS X (10.7.3)