macos/set_finder_comment
- 603 bytes
- View raw
1#!/usr/bin/env bash
3set -o errexit
4set -o nounset
6if (( $# != 2 ))
7then
8 echo "Usage: $0 PATH COMMENT" >&2
9 exit 1
10fi
12# $ set_finder_comment src/_posts/2012/2012-12-30-hypercritical.md Hypercritical
13# 2025-02-25 23:16:10.894 osascript[60436:891948] CFURLGetFSRef was passed a URL which has no scheme (the URL will not work with other CFURL routines)
14FILE_PATH="$(realpath "$1")"
15COMMENT="$2"
17osascript -e '
18 on run argv
19 set filepath to (POSIX file (item 1 of argv) as alias)
20 tell application "Finder" to set the comment of filepath to (item 2 of argv)
21 end run
22' "$FILE_PATH" "$COMMENT"