我会使用这样的shell脚本:
mkdir -p icons
i=1
for a in /Applications/*.app; do
name=${a%.app}
name=${name##*/}
comments=$(osascript -e 'on run {a}
tell app "Finder" to comment of (POSIX file a as alias)
end' "$a")
icon=$(defaults read "$a/Contents/Info.plist" CFBundleIconFile)
[[ $icon != *.* ]] && icon="$icon.icns"
sips "$a/Contents/Resources/$icon" -Z 128 -s format png -o icons/$i.png
output+="<div style=\"clear:both;width:600px;margin:0 auto\">
<div style=float:left><h2>$name</h2><div>$comments</div></div>
<img style=float:right src=\"icons/$i.png\">
</div>
"
let i++
done
echo "$output" > index.html
open index.html
Spotlight 注释通常存储为扩展属性和 .DS_Store 文件。如果您使用 Finder 更改您没有写入权限的文件或文件夹的注释(如默认情况下某些应用程序包),注释仅存储在 .DS_Store 文件中,因此无法使用 xattr 读取或 mdls。