现在的位置: 首页 > 综合 > 正文

自己DIY 一键 显示和 隐藏 mac os 文件 的小插件

2013年02月28日 ⁄ 综合 ⁄ 共 739字 ⁄ 字号 评论关闭

Mac系统下默认是不显示隐藏文件,一般要借助Onyx或者在终端使用命令来显示。其实可以通过Apple Script来简化这个操作。

步骤:

打开“应用程序”──“使用工具”──“AppleScript编辑器”,输入下面的代码,存储为应用程序即可。


try
	do shell script "defaults read com.apple.finder AppleShowAllFiles"
on error
	get 0
end try

set i to (result + 1) mod 2 -- Get opposite of current value 

tell application "Finder"
	activate
	get item (i + 1) of {"Hide", "Show"}
	display dialog (result & " all hidden files in Finder?") buttons {"Cancel", (result & " Hidden Files")} default button 2 with icon note
	quit
end tell

delay 0.5

try
	do shell script "defaults write com.apple.Finder AppleShowAllFiles " & i
	launch application "Finder"
on error errorMsg number errorNum
	display dialog "Error (" & errorNum & "):" & return & return & errorMsg buttons "Cancel" default button 1 with icon caution
end try

 

运行后会重启Finder并显示隐藏文件,再次运行则恢复隐藏。

运行结果为:


为了方便使用,我们还可以把它拖到Finder的工具栏上,就像图中那样。


抱歉!评论已关闭.