-- made by: Olivetti
-- idea & testing: lostreality
-- bugfix & testing: Pill
on open finderObjects
repeat with f in (finderObjects)
if name of (info for f) ends with ".jpg" or name of (info for f) ends with ".jpeg" or name of (info for f) ends with ".png" or name of (info for f) ends with ".psd" or name of (info for f) ends with ".tif" or name of (info for f) ends with ".tiff" then
try
set thefile to quoted form of POSIX path of f
--display dialog thefile
do shell script "read_tag=\"com.apple.metadata:kMDItemWhereFroms\"; write_tag=\"Creator\"; PATH=/usr/local/bin:$PATH; xattr -px \"$read_tag\" " & thefile & " &>/dev/null && src=$(xattr -px \"$read_tag\" " & thefile & " | xxd -r -p | plutil -convert xml1 -o - - | sed -e 's/<[^>]*>//g' | xargs) && exiftool -\"$write_tag\"=\"$src\" -overwrite_original_in_place " & thefile & " &>/dev/null"
on error err
beep
display dialog "Error: " & err & return & thefile
--delay 1
end try
end if
end repeat
--say "done."
do shell script "afplay /System/Library/Sounds/Glass.aiff"
end open