2012-03-05 16 views
2

我做了一個蘋果腳本來卸載卷時我並不需要它,然後當我點擊應用程序再次將其安裝盤...檢查是否存在的AppleScript

林在Automator中創建它並且代碼看起來是這樣的:

if disk "UNIVERSAL" exists then 

    do shell script "diskutil unmount /volumes/UNIVERSAL" 

    else 

    do shell script "diskutil mount /volumes/UNIVERSAL" 

end if 

我得到的disk "UNIVERSAL" exists錯誤請幫助...

感謝 本

+0

而且它是一個問題嗎? – beryllium 2012-03-05 07:22:24

回答

1

使用Finder中的替代方法是這樣...

set diskName to "UNIVERSAL" 

if diskName is in (do shell script "/bin/ls /Volumes") then 
    -- unmount 
else 
    -- mount 
end if 
4

告訴應用程序「Finder」塊中的if語句是什麼?

tell application "Finder" 
if disk "Mac OS X" exists then 
    beep 
end if 
end tell 
1
  • 檢查是否存在的文件夾是不是真的安全,如果先前的裝入失敗是什麼?
  • 如果有什麼是目錄安裝UNIVERSAL-1或通用電影...等

到取景器更安全,更密切的替代方法是

set theVolume to "/Volumes/UNIVERSAL" 
set mountedVolumes to every paragraph of (do shell script "mount | awk -F' on ' '{print $2}' | awk -F' \\\\(' '{print $1}'") 
if theVolume is in mountedVolumes then 
    --Volume is mounted 
else 
    --volume is not mounted 
end if