Skip to content

Instantly share code, notes, and snippets.

@atr000
Created September 8, 2010 06:46
Show Gist options
  • Save atr000/569739 to your computer and use it in GitHub Desktop.
Save atr000/569739 to your computer and use it in GitHub Desktop.
on run {input, parameters}
repeat with n in input
set z to (n as alias)
set n to (info for z)'s name
tell application "Finder" to set P to z's container as alias
set zP to POSIX path of (P as text) & n
try
set the_URL to do shell script "mdls -name kMDItemWhereFroms" & space & zP & space & "|" & space & "grep -o '\"'.*'\"'"
set the_URL to replace_chars(the_URL, "\"", "")
tell application "Finder"
set comment of file ((P as text) & n) to the_URL
end tell
end try
end repeat
end run
on replace_chars(this_text, wrongo, righto)
set AppleScript's text item delimiters to the wrongo
set the item_list to every text item of this_text
set AppleScript's text item delimiters to the righto as string
set this_text to the item_list as string
set AppleScript's text item delimiters to ""
return this_text
end replace_chars
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment