I see a number of posts on how to delete the WhereFrom extended attributes data, but I would like to do the opposite and extract the information into a file.

I download Creative Commons photos from Flickr and provide photo credits on my blog.

I would like to set up a Folder Action that extracts the WhereFrom URL from the photo into a file, that way I can easily copy-paste the URL into my blog photo credit. It would also give me an archive of all my downloads.

I tried to reverse-engineer some of the delete scripts on StackExchange but didn't have any luck.

1 Answer 1


Try this in a Run Applescript Action:

    on run {input, parameters}
    set filePath to "/Users/UserName/Documents/WhereFroms.txt"

    repeat with i from 1 to number of items in input
        set this_item to item i of input
        tell application "Finder" to set displayedname to displayed name of this_item
        set this_item to this_item as string
        set this_item to POSIX path of this_item as string
        set theFroms to (do shell script "mdls -name kMDItemWhereFroms " & quoted form of this_item)
        set allFroms to (do shell script "echo " & quoted form of theFroms & "| cut -d'(' -f2- |cut -d')' -f1 ")--strip crap

        set WhereFroms to "File: " & displayedname & return & "From:  " & (allFroms & return & return)
        do shell script "echo " & quoted form of WhereFroms & "  >> " & quoted form of filePath
    end repeat

end run

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .