Last active
December 25, 2015 06:49
-
-
Save rommelfs/6935325 to your computer and use it in GitHub Desktop.
add comments to file in metadata to be indexed by spotlight (OS X centric)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
FILENAME="$1" | |
OLDCOMMENT="`mdls -r -nullMarker "" -n kMDItemFinderComment \"$FILENAME\"`" | |
echo "Old comment: $OLDCOMMENT" | |
while read LINE | |
do | |
COMMENT="$OLDCOMMENT $LINE" | |
done | |
echo "Updated comment: $COMMENT" | |
PATH=`pwd` | |
FULLPATH="$PATH/$FILENAME" | |
echo $FULLPATH | |
/usr/bin/osascript -e "set filepath to POSIX file \"$FULLPATH\"" \ | |
-e "set the_File to filepath as alias" \ | |
-e "tell application \"Finder\" to set the comment of the_File to \"$COMMENT\"" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment