Created
January 6, 2020 09:28
-
-
Save hguandl/199906d9b979e0ecda9263f3d443c9d2 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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