Etiqueta

Mostrando entradas con la etiqueta AppleScrip. Mostrar todas las entradas
Mostrando entradas con la etiqueta AppleScrip. Mostrar todas las entradas

01 marzo 2012

AppleScrip para montar y desmontar discos


set diskName to "NombreDelDisco"
tell application "Finder"
if disk diskName exists then
    eject disk diskName
else
    tell current application
        set deviceLine to (do shell script "diskutil list | grep \"" & diskName & "\" | awk '{ print substr($0,69,9) }'")
        if deviceLine = "" then
            display dialog "El disco \"" & diskName & "\" no pudo encontrarse." 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