Delete 'Where From' metadata from files

Dec 08, '10 07:30:00AM

Contributed by: renaultssoftware

Recently, I was asked to find a way to delete the 'Where From' link in the Get Info box of the Finder, because the info key was too incriminating. I didn't want to download any software, so I set about looking in the file's metadata. After running mdls and xattr on the file, I finally hit upon a way to delete the key.

If you run xattr on your downloaded file, like this:

xattr /Path/To/File

You'll get a key named com.apple.metadata:kMDItemWhereFroms. To delete this key in the Terminal, run:

xattr -d com.apple.metadata:kMDItemWhereFroms /Path/To/File

I knew I would have to do this often, so instead of running a shell script every time I wanted to strip the Where From, I wrote an AppleScript:

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
I then saved it on the desktop as an application. Now, I can drag and drop as a batch operation to delete the metadata key.

[crarko adds: I tested this, and it works as described.]

Comments (16)


Mac OS X Hints
http://hints.macworld.com/article.php?story=20101206161739274