Last active
September 15, 2023 16:22
-
-
Save SKaplanOfficial/2ed9ae45a5a5337fc9dd97a4c2a82afe to your computer and use it in GitHub Desktop.
Using PyXA to get the number of shortcuts in each shortcuts folder
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
# 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