You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
40 lines
767 B
40 lines
767 B
9 years ago
|
#
|
||
|
# Tells Finder where a file was downloaded from
|
||
|
#
|
||
|
# List of spotlight metadata keys https://developer.apple.com/library/mac/#docum
|
||
|
#
|
||
|
# Authors:
|
||
|
# josho
|
||
|
#
|
||
|
|
||
|
local url
|
||
|
local success
|
||
|
|
||
|
if (( $# < 2 )); then
|
||
|
cat >&2 <<EOF
|
||
|
Usage: $0 <url> [file ...]
|
||
|
EOF
|
||
|
return 1
|
||
|
fi
|
||
|
|
||
|
url=$1
|
||
|
shift
|
||
|
|
||
|
while (( $# > 0 )); do
|
||
|
if [[ -f "$1" ]]; then
|
||
|
# A json plist containing the Downloaded from URL
|
||
|
local plist='["'"$url"'"]'
|
||
|
|
||
|
# Convert to a hexdump representation of a binary plist
|
||
|
# In xxd set the max column count to avoid line breaks
|
||
|
local binplist=`echo -n "$plist" | plutil -convert binary1 -o - - | xxd -p -c 256`
|
||
|
|
||
|
xattr -wx 'com.apple.metadata:kMDItemWhereFroms' "$binplist" "$1"
|
||
|
|
||
|
else
|
||
|
print "$0: cannot read: $1" >&2
|
||
|
success=1
|
||
|
fi
|
||
|
shift
|
||
|
done
|