Skip to content

Instantly share code, notes, and snippets.

@hguandl
Created January 6, 2020 09:28
Show Gist options
  • Save hguandl/199906d9b979e0ecda9263f3d443c9d2 to your computer and use it in GitHub Desktop.
Save hguandl/199906d9b979e0ecda9263f3d443c9d2 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python3
import os
import xattr
APP_DIR = "/Applications"
ATTR = "com.apple.quarantine"
def remove_r(path: str):
if ATTR in xattr.listxattr(path):
xattr.removexattr(path, ATTR)
if (os.path.isdir(path)):
for f in os.listdir(path):
remove_r(os.path.join(path, f))
for app in os.listdir(APP_DIR):
app_path = os.path.join(APP_DIR, app)
if ATTR in xattr.listxattr(app_path):
try:
remove_r(app_path)
except PermissionError as e:
print(f'No permission for \"{app_path}\", skipped')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment