MACRO: [KM] DELETE All Variables Except Those on Keep List
Use this macro to delete ALL KM variables except those you want to keep.
If you find any bugs or issues, or would like to make suggestions for improvement, please post below.
See Technical Note at the bottom of this post.
Note: 2019-08-03 16:49 GMT-5
Now that we have Local and Instance Variables , the best practice (IMO) is to use those rather than Global variables. Thus, this macro should not be needed as often.
You might also be interested in this macro:
MACRO: [KM] DELETE List of KM Variables [SUB-MACRO]
List of KM Variables to Keep
NOTICE: Be sure to edit the KEEP List in the macro before you use to delete your variables. Each KM Variable should be put on a separate line, with just the Variable name. Do NOT use %, space, or any other characters before/after the variable name.
You can run the first time, and CANCEL to get a list of your variables on the clipboard, which you can then edit in a text editor like TextWrangler to build your keep list.
Output of Macro Results
If you click the "Delete" button, then the process will continue and your non-keep variables will be deleted. The results are put on the Clipboard, and shown in a KM window:
• Delete ALL KM Variables EXCEPT those on the KEEP List
• To just get list of existing variables, CANCEL when prompted to confirm deletion. No variables are deleted if CANCELED.
• Results are copied to Clipboard, and displayed in window.
HOW TO USE:
(1) Edit the KEEP List below ### IMPORTANT ###
(2) Run this macro
(3) CANCEL to stop process and display list of current KM Variables
# TECHNICAL NOTE
Neither JXA nor AppleScript can actually see ALL of the KM Variables that are shown in the KM Preferences. So you may see some KM Variables, other than on your Keep List, remaining AFTER you run the macro.
From Peter (@peternlewis):
The preference pane includes variables that are referenced by any macro or that have a value and that is not %Delete%.
The variables result from AppleScript includes variables that have a value and that is not %Delete%.