1

我想将我 Mac 上所有应用程序的精美清单发送给朋友,并附上图标和简短评论。我将评论写为 Finder 评论(在每个应用程序的“获取信息”窗口中)。我尝试使用名为“打印窗口”的有前途的应用程序,但它会截断我的评论。然后我试图找到一个 AppleScript 解决方案(在 TextEdit 中编译一个列表),但似乎没有简单的方法可以做到这一点——至少在不安装一些额外的东西的情况下(我不想这样做)。

如果我能得到一个可编辑的列表,在 TextEdit 中编辑它会很好:应用程序名称、应用程序图标、评论。

有谁知道解决方案?

谢谢你。

4

1 回答 1

3

我会使用这样的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。

于 2013-05-26T19:27:58.143 回答