ior*_*ori 11 terminal applescript finder osx-yosemite
我在优胜美地,我想切换隐藏/显示Mac上的所有隐藏文件.
每次,我想这样做,我必须去Terminal.app并运行这些命令:
显示
defaults write com.apple.finder AppleShowAllFiles TRUE
隐藏
defaults write com.apple.finder AppleShowAllFiles FALSE
我想知道是否有一个更好的调整,只需点击一下按钮即可实现这一目标.
更新,考虑所有评论:
try
set state to (do shell script "defaults read com.apple.finder AppleShowAllFiles") as boolean
on error
set state to false
end try
do shell script "defaults write com.apple.finder AppleShowAllFiles " & (not state)
try
tell application "Finder"
set w to front window
set t to (get target of w)
if t is not startup disk then
set the target of w to startup disk
else
set the target of w to home
end if
set the target of w to t
end tell
end try
tell application (path to frontmost application as text)
display notification "ShowAllFiles is now " & (not state)
end tell
Run Code Online (Sandbox Code Playgroud)
将脚本导出为应用程序,然后将应用程序 cmd 拖至 Finder 窗口工具栏。