2015-10-09更新:10.11 El Caption对隐藏文件的显示与隐藏做了小幅度修改,本文对此进行了更新。
在OS X中,控制隐藏文件的显示与隐藏需要在终端中输入指令,十分繁琐。为了解决这个问题,我用AppleScript编写一个小程序,用于控制隐藏文件的显示与隐藏,奇数次运行时,显示隐藏文件;偶数次运行时,隐藏隐藏文件。
初学AppleScript,代码写的不好,在此将代码写出,欢迎各位网友改进。
property countTimes : 0
set countTimes to countTimes + 1
set judge to countTimes mod 2
if judge = 1 then do shell script "defaults write com.apple.finder AppleShowAllFiles -bool true"
if judge = 1 then do shell script "killall Finder"
if judge = 1 then display dialog "隐藏文件已显示"
if judge = 0 then do shell script "defaults write com.apple.finder AppleShowAllFiles -bool false"
if judge = 0 then do shell script "killall Finder"
if judge = 0 then display dialog "隐藏文件已隐藏"