How to remove xattr com.apple.quarantine from all .webarchive files with that extended attribute?

Solution 1:

find . -iname '*.webarchive' -print0 | xargs -0 xattr -d com.apple.quarantine
  • will remove (xattr -d) the com.apple.quarantine extended attribute
  • from all files with an extension of .webarchive (-iname '*.webarchive')
  • located in the current directory and its subdirectories (. -depth, where the -depth is implied)
  • going through xargs (-print0 | xargs -0) to avoid problems with filenames containing spaces and other special characters (a similiar goal can be accomplished with slightly reduced efficiency by using find . -iname '*.webarchive' -exec xattr -d '{}' \;).

Explanation of the efficiency difference:

Whenever the syntax allows for it such as in this case, xargs assembles one or more command lines such as xattr -d com.apple.quarantine /path/to/file1.webarchive /path/to/fileN.webarchive

while the in-my-opinion easier to remember find-only version repeats the command every time: xattr -d com.apple.quarantine /path/to/file1.webarchive ; xattr -d com.apple.quarantine /path/to/fileN.webarchive