Extract "Get Info" Metadata From File

I have an entire folder of files from which I need to extract all the “Where From” strings into a single text file that I can import into Excel. I found an Applescript (see below) that shows how to delete that attribute, so what I need to do is modify it so that it loops through all the files in a folder and extracts the strings and save them.

What I need in the end is a text file saved on the Desktop that has the name of each file being processed, then a tab or comma, and then the “Where From” string, each on a separate line.

I have basically no knowledge of how to do this, and my only other option is to spend days doing it manually.

If it could be done as a drag and drop so I could just drag the folder over, all the better.

Thanks so much for your help!

on deleteWhereFrom(fileToClean)
 try
  set posixPath to quoted form of POSIX path of fileToClean
  do shell script "xattr -d com.apple.metadata:kMDItemWhereFroms " & posixPath
 end try
end deleteWhereFrom
on open imgs
 repeat with i in imgs
  deleteWhereFrom(i)
 end repeat
end open
on run
 set imgs to choose file with multiple selections allowed
 repeat with i in imgs
  deleteWhereFrom(i)
 end repeat
end run

p.s. I am brand new to this forum, so I hope I posted this right!

Hi,

welcome to MacScripter.

Yes, you’ve posted it right, but please use the applescript tags around the code.
In the edit form highlight the code and press the AppleScript button

You can also edit the post.