2012-03-05 1 views
2

내가 필요하고 내가 응용 프로그램을 클릭하면 다음 다시 설치하지 않는 경우 볼륨을 마운트 해제 사과 스크립트를 만들고있어 존재 여부 그리고 코드는 다음과 같습니다체크 디스크는</p> <p>임 자동화에 그것을 만드는 ... AppleScript로

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

답변

1

Finder를 사용하는 대신이 많이 ...

set diskName to "UNIVERSAL" 

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

tell 애플리케이션 "Finder"블록 내의 if 문은 차단됩니까? 폴더가 존재하는 경우

tell application "Finder" 
if disk "Mac OS X" exists then 
    beep 
end if 
end tell 
1
  • 정말 안전이하는 이전 무엇을 실패 마운트하지 않으면됩니다 확인?
  • 만약에이 디렉토리에 장착 UNIVERSAL-1 또는 UNIVERSAL MOVIES ... 등

파인더에 대한 더 안전하고 더 가까운 대안

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