Skip to content

Instantly share code, notes, and snippets.

@sunsong
Created August 25, 2022 08:41
Show Gist options
  • Select an option

  • Save sunsong/a8f91cbed7b628decba6c62baef70c4f to your computer and use it in GitHub Desktop.

Select an option

Save sunsong/a8f91cbed7b628decba6c62baef70c4f to your computer and use it in GitHub Desktop.
Get Installed Applications in MacOS
#!/usr/bin/python3
# https://stackoverflow.com/questions/50708348/using-python-to-find-mac-uuid-serial-number
import os
import subprocess
irrelevant_files = [
".localized",
]
def get_serial_number():
cmd = "system_profiler SPHardwareDataType | awk '/Serial Number/ {print $4}'"
result = subprocess.run(cmd, stdout=subprocess.PIPE, shell=True, check=True)
serial_number = result.stdout.strip().decode()
return serial_number
def get_installed_applications():
listed_items = os.listdir("/Applications")
apps = []
for item in listed_items:
if item not in irrelevant_files:
apps.append(item)
return [app.split(".app")[0] for app in apps]
def main():
serial_number = get_serial_number()
installed_apps = ", ".join(get_installed_applications())
print("Your Mac Serial Number: %s" % serial_number)
print("The apps you installed: %s" % installed_apps)
if __name__ == "__main__":
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment