Skip to content

Instantly share code, notes, and snippets.

@SKaplanOfficial
Last active September 15, 2023 16:22
Show Gist options
  • Save SKaplanOfficial/2ed9ae45a5a5337fc9dd97a4c2a82afe to your computer and use it in GitHub Desktop.
Save SKaplanOfficial/2ed9ae45a5a5337fc9dd97a4c2a82afe to your computer and use it in GitHub Desktop.
Using PyXA to get the number of shortcuts in each shortcuts folder
# Tested with PyXA 0.1.0
import PyXA
app = PyXA.Application("Shortcuts")
folders = app.folders()
# Method 1 - Standard iteration
summary = []
for folder in folders:
folder_name = folder.name
num_shortcuts = len(folder.shortcuts())
summary.append((folder_name, num_shortcuts))
print("Method 1:", summary)
# Method 2 - Use bulk methods
shortcuts_by_folder = zip(folders.name(), folders.shortcuts())
summary = [(name, len(shortcuts)) for name, shortcuts in shortcuts_by_folder]
print("Method 2:", summary)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment