Skip to content

Instantly share code, notes, and snippets.

@dmitryd
Last active August 29, 2015 14:23
Show Gist options
  • Save dmitryd/ceb93c68d25bb95bc451 to your computer and use it in GitHub Desktop.
Save dmitryd/ceb93c68d25bb95bc451 to your computer and use it in GitHub Desktop.
Change source URL of the file in the OS X metadata from shell
#/bin/bash
if [ ! -e "$2" ] ; then
echo "Format: `basename $0` url file"
echo ""
echo "Sets the source URL of the file."
echo ""
exit 1
fi
URL="$1"
ENCODED_URL=`echo \(\'$URL\'\) | plutil -convert binary1 -o - - | xxd -p -c 16 -u`
xattr -xw com.apple.metadata:kMDItemWhereFroms "$ENCODED_URL" "$2"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment