1

I would like to send to a friend a nice listing of all the apps on my Mac, with icons and brief comments. I wrote the comments as Finder comments (in the "Get Info" window of each app). I tried to use a promising application called "Print Window", but it truncates my comments. Then I tried to find an AppleScript solution (to compile a list in TextEdit), but it seems there is no simple way to do it -- at least not without installing some additional stuff (which I don't want to).

It would be nice if I could get an editable list, to edit it in TextEdit: app name, app icon, comment.

Does anyone know of a solution?

Thank you.

Amenhotep
  • 920
  • 1
  • 13
  • 18

1 Answers1

3

I'd use a shell script like this:

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 comments are normally stored as both extended attributes and in .DS_Store files. If you use Finder to change the comments for a file or folder you don't have write permission to (like some application bundles by default), the comments are only stored in a .DS_Store file, so they can't be read with xattr or mdls.

Lri
  • 26,768
  • 8
  • 84
  • 82
  • Wow, it worked like a charm! The only thing I needed to research a bit was how to actually execute the script. This helped: http://stackoverflow.com/questions/8409946/how-do-i-make-this-file-sh-executable-via-double-click. So thanks a lot! – Amenhotep May 26 '13 at 20:39