Skip to content

Instantly share code, notes, and snippets.

View tobias-johansson's full-sized avatar

Tobias Johansson tobias-johansson

View GitHub Profile
@paulp
paulp / kMDItemWhereFroms.sh
Created May 9, 2015 17:19
Exploit extended file attributes to figure out where some downloads came from.
#!/usr/bin/env bash
#
for file in "$@"; do
attr="$(xattr -p com.apple.metadata:kMDItemWhereFroms "$file" 2>/dev/null)"
url () {
echo "$attr" | xxd -r -p | plutil -convert xml1 -o - - | \
ack --output='$1' '(?:<string>)(.+?)</string>' | head -n1
}