代碼: 選擇全部
try
if word -1 of (do shell script "defaults read com.apple.finder | grep AppleShowAllFiles") = "true" then
do shell script "defaults write com.apple.finder AppleShowAllFiles false"
else
do shell script "defaults write com.apple.finder AppleShowAllFiles true"
end if
on error
do shell script "defaults write com.apple.finder AppleShowAllFiles true"
end try
tell application "Finder" to quit
delay 3
tell application "Finder" to activate
上述指令 toggle Finder 顯示 / 不顯示隱藏檔。
略述:如 ~/Library/Preferences/com.apple.finder.plist 內未有 AppleShowAllFiles 此 key 或 其值為 false;則設為 true。反之,設定 AppleShowAllFiles 為 false。
用 defaults write 改動 plist,Finder 需再啟動才見效。
[1] 參看:File-System Structure and Visibility。