Created
September 8, 2010 06:46
-
-
Save atr000/569739 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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