Delete All Variables Except…

Hey Tom,

The current form of that AppleScript is not very different than the one you mention, and it runs in a bit less than 8 seconds with your ~1600 variable data set if the Keyboard Maestro preferences window is closed.

(If the prefs window is open it takes right at 8 seconds.)

This is on my venerable Mid-2010 MacBook Pro.

-Chris

--------------------------------------------------------------------------------
# Auth: Christopher Stone
# dCre: 2016/07/28 14:42
# dMod: 2017/02/06 15:17
# Appl: Keyboard Maestro Engine
# Task: Delete Variables Whose Name is not in the Exclusion List.
# Libs: None
# Osax: None
# Tags: @Applescript, @Script, @Keyboard_Maestro_Engine, @Delete, @Variables, @Exclusion_List
--------------------------------------------------------------------------------

set pinnedVariableList to items 1 thru -2 of {¬
   "ENV_PATH", ¬
   ""}

tell application "Keyboard Maestro Engine"
   set varNameList to name of variables
   
   repeat with varName in varNameList
      if varName is not in pinnedVariableList and varName does not start with "DND_" then
         try
            setvariable varName to "%Delete%"
         end try
      end if
   end repeat
   
end tell

--------------------------------------------------------------------------------
2 Likes