利用Automator快速删除扩展属性(解决文件灰白色)
2018-08-25 本文已影响11人
雷系泡泡
不知道什么原因,在macOS中,NTFS格式的移动硬盘中的文件总是莫名变成灰白色,经过搜索查找到原因是文件多了扩展属性"@",如图所示:
ls -la.png
服务列表->Delete xttr.png
Automator-AppleScript-DeleteXttr.png

查询一番,找到一个有趣的解决方式:
xattr -d -r com.apple.FinderInfo file
但是,似乎并不能根治。。
下次使用的时候,还是会出现这情况,我呢,又很懒。。
所以利用Automator创建了一个“懒人服务”,每次从服务列表中执行上面的命令,完美✌

服务“Delete xttr”创建步骤如下:
-
打开Automator,新建选择“服务”
Automator-选择服务.png
-
修改“服务”的使用范围,如图所示:
Automator-选择服务范围.png
-
从左侧的“操作”中,找到分类“实用工具”,将“运行 AppleScript”直接拖拽到右侧的运行区域
Automator-选择运行AppleScript.png
-
在右侧“运行 AppleScript”中输入以下AppleScript代码
on run {input, parameters}
set itemCount to get the count of input
set startIndex to 1
repeat itemCount times
set currentItem to get item startIndex of input as text
set currentItem to get POSIX path of currentItem
do shell script "xattr -d -r com.apple.FinderInfo " & currentItem
set startIndex to startIndex + 1
end repeat
return input
end run

- 大功告成啦,直接保存就好了,这个服务保存在
~/Library/Services/
PS:
- 单选或多选文件,包括文件夹都可以直接执行喔
- 在步骤4中,并不能直接运行调试,如图所示:
Automator-不接收输入信息.png
如需要调试,需要添加“获取指定的访达项目”,即可直接进行调试。Automator-获取指定的访达项目.png
调试结束后,记得“停用”或者“移除”喔Automator-停用.png