Help - Search - Members - Calendar
Full Version: Unmount volumes at login
InsanelyMac Forum > Apple World > Mac Programming and Development > AppleScript and Automator
BlackShadowWolf
Hey everyone, I finished my first real AppleScript last night. What it does, is that it will unmount specified volumes. Simple, but it also does it based on the computer architecture. I found this to be important as I have a firewire drive with 5 partitions, and want to close 4 of them, based on what system im running. Take a look and feel free to play with it smile.gif.


CODE
tell application "Finder"
    display alert "Unmounting extra volumes, please wait." as informational buttons "OK" giving up after 2
end tell
tell application "Terminal"
    activate
    set HardwareType to do shell script "uname -p"
    if HardwareType is "i386" then
        do script "diskutil unmount \"/Volumes/Intel Install\"" in ¬
            window frontmost
        delay 1
        do script "diskutil unmount \"/Volumes/PowerPC Install\"" in ¬
            window frontmost
        delay 1
        do script "diskutil unmount \"/Volumes/PowerPC Firewire\"" in ¬
            window frontmost
        delay 1
        do script "diskutil unmount \"/Volumes/Media Files\"" in ¬
            window frontmost
    end if
    if HardwareType is "PPC" then
        do script "diskutil unmount \"/Volumes/Intel Install\"" in ¬
            window frontmost
        delay 1
        do script "diskutil unmount \"/Volumes/PowerPC Install\"" in ¬
            window frontmost
        delay 1
        do script "diskutil unmount \"/Volumes/Intel Firewire\"" in ¬
            window frontmost
        delay 1
        do script "diskutil unmount \"/Volumes/Media Files\"" in ¬
            window frontmost
    end if
    delay 3
    quit
end tell
tell application "Finder"
    display alert "System is now ready." as informational buttons "OK" giving up after 2
end tell
Zealot
i ll be teting this right away.

gt
BlackShadowWolf
I had some problems with this original script as sometimes it would go too fast that not all the volumes wount unmount. I suggest increasing the delay times to 2 or 3 seconds so theres adequate time for each command to finish smile.gif.
alicheusz
Apple script is heavy and take some time to load. Better solution is to put shell script in startup files


CODE
cd /System/Library/StartupItems/Disks/

sudo nano Disks


add after "/sbin/autodiskmount -va"

CODE
PATH=$PATH:/usr/local/bin
export PATH
umount /Volumes/Win_XP
umount /Volumes/30\ GB\ NTFS


where Win_XP and 30\ GB\ NTFS are disk that you want to unmount
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.