|
|
Set Comment to "Where From" URI.scpt
Save this script into Library/Scripts/Applications/Finder/ and you can easily invoke it from the Finder via the Script Menulet. Works on the frontmost window. Works on either a Get Info window, or a Finder window with one or more selected files:
tell application "Finder" if the class of window 1 is information window then -- If a Get Info window fetchWherefromData(item of window 1 as alias, true) of me else if the class of window 1 is Finder window then -- If a regular Finder window repeat with thisItem in the selection as list -- may have multiple files selected fetchWherefromData(thisItem as alias, true) of me end repeat end if end tell beep (* Grab the WhereFrom metadata; If "setComment" is true, put it into the file's comment box *) on fetchWherefromData(theFile, setComment) set theURI to do shell script "mdls -name kMDItemWhereFroms " & quoted form of POSIX path of theFile & " | perl -ne 'print if s/.*"(.*)".*$/\1/'" -- shell script to fetch metadata; using Perl to extract URI from mdls's messy output if setComment = true then -- Put it into the file's comment box? if theURI ≠ "" then -- did we get a URI? tell application "Finder" set theComment to comment of theFile if theComment = "" then -- if no comment exists, put in the URI set comment of theFile to theURI else if theComment ≠ theURI then -- if the comment is the URI, do nothing, else append the URI to the end of the comment set comment of theFile to theComment & return & theURI end if end tell end if end if return theURI end fetchWherefromData |
SearchFrom our Sponsor...Latest Mountain Lion HintsWhat's New:HintsNo new hintsComments last 2 daysLinks last 2 weeksNo recent new linksWhat's New in the Forums?
Hints by TopicNews from Macworld
From Our Sponsors |
|
Copyright © 2014 IDG Consumer & SMB (Privacy Policy) Contact Us All trademarks and copyrights on this page are owned by their respective owners. |
Visit other IDG sites: |
|
|
|
Created this page in 0.11 seconds |
|