21

Spread across multiple file system I have numerous .webarchive files that were saved by OmniWeb. So for example:

sh-3.2$ ls -@ 2012-03-19.webarchive 
2012-03-19.webarchive
sh-3.2$ ls -@l 2012-03-19.webarchive 
-rw-r--r--@ 1 gjp22  staff  3722852 19 Mar  2012 2012-03-19.webarchive
    com.apple.quarantine         26 
sh-3.2$ xattr -l 2012-03-19.webarchive 
com.apple.quarantine: 0000;4f66fcc8;OmniWeb.app;

Those files are treated as from an unidentified developer. I can open each one with a Control-click but it's tedious.

So I'd like a command, probably involving find(1), to remove all such extended attributes.

3 Answers 3

30
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

1
  • 3
    find will do the same efficient filepath-assembling if you end it with \+ instead of \;. May 1, 2016 at 22:28
2

The version of xattr I have on my macOS 11.6 claims to have an -r switch

-r: act recursively

So you should be able to use

xattr -d com.apple.quarantine -r file.webarchive
3
  • Much more convenient, this worked on 12.6: xattr -d com.apple.quarantine -r my_dir/
    – xref
    Jul 15, 2022 at 2:22
  • 12.5 hasn't even been released! How are you on 12.6? Anyway thanks, I edited my answer to include the attribute.
    – jasonology
    Jul 20, 2022 at 2:00
  • the fattest of fingers, 12.4 is what my little sausages meant to type
    – xref
    Jul 23, 2022 at 7:42
1

here is a more automated way to accomplish this:

open automator - select "service"

paste this

on run {input, parameters}
    tell application "Terminal"
        activate
        set filesString to ""
        repeat with file_ in input
            set filesString to filesString & " " & quoted form of (POSIX path of file_)
        end repeat
        do script "xattr -r -d com.apple.quarantine" & filesString
    end tell
    return input
end run

Make sure "files or folders" is selected for "Service receives selected". Make sure "Finder" is selected for "in"

then hit save and name it unquarantine, go to the folder or file you want to remove from quarantine and right click and select unquarantine

https://forums.macrumors.com/threads/%E2%80%9Cverifying%E2%80%9D-upon-opening-every-file.2065395/page-2#post-25134721

You must log in to answer this question.

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