Last active
December 24, 2019 14:14
-
-
Save moyashi/dff522a355ea19dfb8bcd6b46b5085cf to your computer and use it in GitHub Desktop.
SDカード等のMS-DOSフォーマットのディスクをイジェクトするAppleScript
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
display notification "イジェクト処理開始" | |
set dl to {} | |
repeat with l in every paragraph of (do shell script "mount | grep -e 'msdos\\|exfat' | awk '{print $1}'") | |
set end of dl to (do shell script "diskutil info " & l & " | grep 'Volume Name:' | sed -e 's/Volume Name: //' | sed -e 's/^ *//'") | |
end repeat | |
if ((count of dl) is greater than 0) then | |
tell application "Finder" | |
repeat with i in dl | |
if (exists disk i) then | |
eject disk i | |
repeat 20 times | |
delay 0.5 | |
if (not (exists disk i)) then | |
display notification i & "がイジェクトされました" | |
exit repeat | |
end if | |
end repeat | |
end if | |
end repeat | |
end tell | |
else | |
display notification "イジェクト対象のディスクがありませんでした" | |
end if |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
BetterTouchToolでCommand + Ctrl + Eに割り当てて実行しています。
「Apple Scriptを実行する(ブロック)」で実行しないと通知が表示されません。
「Apple Scriptを実行する(バックグラウンドで非同期)」でも実行できますが、通知が表示されません。