Skip to content

Instantly share code, notes, and snippets.

@korylprince
Last active December 9, 2020 17:40
Show Gist options
  • Save korylprince/313df8ffc6d78dc5f26f41fcc206daa4 to your computer and use it in GitHub Desktop.
Save korylprince/313df8ffc6d78dc5f26f41fcc206daa4 to your computer and use it in GitHub Desktop.
macOS Cleanup Script
#!/usr/bin/python
import os
import shutil
system_folders = [
"/Applications/AVer+.app",
"/Applications/AVerVision 2.app",
"/Applications/Algodoo.app",
"/Applications/GIMP.app",
"/Applications/GarageBand.app",
"/Applications/Keynote.app",
"/Applications/LibreOffice.app",
"/Applications/Numbers.app",
"/Applications/Pages.app",
"/Applications/STAAR Online Testing Program",
"/Applications/Sphere.app",
"/Applications/Stykz.app",
"/Applications/TestNav.app",
"/Applications/iBooks Author.app",
"/Applications/iDVD.app",
"/Applications/iMovie.app",
"/Applications/iPhoto.app",
"/Library/Application Support/GarageBand",
"/Library/Application Support/Logic",
"/Library/Application Support/iDVD",
"/System/Library/Caches/com.apple.coresymbolicationd",
"/private/var/db/systemstats",
"/private/var/folders",
"/usr/local/Cellar/go",
]
system_files = [
"/private/var/vm/sleepimage",
"/private/var/vm/swapfile0",
"/private/var/vm/swapfile1",
]
user_folders = [
"/Users/{user}/.Trash",
"/Users/{user}/Library/Application Support/MobileSync/Backup",
"/Users/{user}/Library/Caches/com.apple.iTunes/SubscriptionPlayCache",
"/Users/{user}/Library/Caches/com.google.SoftwareUpdate",
"/Users/{user}/Library/iTunes/iPad Software Updates",
]
for f in system_folders:
shutil.rmtree(f, ignore_errors=True)
for f in system_files:
try:
os.remove(f)
except:
pass
for user in os.listdir("/Users/"):
for f in user_folders:
shutil.rmtree(f.format(user=user), ignore_errors=True)
os.system("df -h /")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment