Howdy folks, recently I was (apparently) confused about how to search for files that are embedded in macros. For whatever reason, when I would search the Editor for a file's name, it would not always give me any results, even if that file was indeed embedded in a macro. So I set out to build a macro that would search my macro database to see if a particular file (or batch of files) were embedded in a macro's actions.
-Chris
MACRO INFORMATION
Download Macro: 27)Files- Search KM Plist File for Embedded File(s) and Tag (for sharing).kmmacros (51 KB)
Screen Recording (click to expand/collapse)
Macro Notes (click to expand/collapse)
- Macros are always disabled when imported into the Keyboard Maestro Editor.
- The user must ensure the macro is enabled.
- The user must also ensure the macro's parent macro-group is enabled.
System Information (click to expand/collapse)
- macOS 13.6
- Keyboard Maestro v11.0
RELEASE NOTES, INSTRUCTIONS AND DISCLAIMER
Purpose of this macro (click to expand/collapse)
This macro is designed to search the Keyboard Maestro master plist file (by creating a duplicate, no action is taken on the actual file itself to avoid any damage to your macro database) to find if the file(s) you selected are embedded in a macro and tag them with a tag of your choice, or remove previously added tags to files that are no longer in the database.
It can be helpful to be able to quickly check which files are currently in use in your macros before making changes to them.
How this macro works (click to expand/collapse)
The KM master plist file is duplicated to a temporary folder in /var/tmp/.
That file is opened in BBEdit, the entire contents is copied to the system clipboard, the file is closed and the temp folder and file are trashed.
The clipboard is then searched for each file name to see if it is in the KM plist file contents.
If it is, it is tagged with Keyboard Maestro and it's path is appended to a variable.
If it is not, it is not tagged, but it's path is appended to a different variable.
If it was previously tagged indicating it was once in the KM plist file but is no longer there, the tag is removed and it's path is appended to another variable.
Files that are not in the plist file and are not tagged are not modified in any way, and their filepath is appended to another variable.
After the clipboard is searched for each file, a display text window appears showing which file(s) were tagged, which ones weren't, which ones had tags removed, which ones didn't need any action taken, and showing that the temp folder was trashed.
How to configure this macro (click to expand/collapse)
Set the purple-colored variables to indicate what tag you would like to add to the files (replace Keyboard Maestro with the name of your tag or leave as is), as well as whether you want to trash the unused files or not (using Yes or No as the value).
How to use this macro (click to expand/collapse)
Select the file(s) you would like to search for and trigger the macro.
You don't have to worry about having directories in your selection as those are skipped automatically.
That's it!
Disclaimer (click to expand/collapse)
TL;DR: I built it and it works for me. You can share/modify it how you want. But don't blame me if it doesn’t work for you
Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
CURRENT VERSION: v3.3.1 Friday, November 03, 2023
Improved searching Editor by using full file path to avoid showing macros with embedded files with the same name but different path
Version History (click to expand/collapse)
v3.3.0 Thursday, November 02, 2023
A prompt with list action now allows you to select a file from those that were found in the KM plist and search the KM Editor for any macros containing that file.
v3.3.0 Thursday, November 02, 2023
A prompt with list action now allows you to select a file from those that were found in the KM plist and search the KM Editor for any macros containing that file.
v.3.2.0 Friday, September 15, 2023
Macro now searches for files that are referenced with an abbreviated tilde in their file path.
v3.1.0 Wednesday, February 22, 2023
Switched to using a named clipboard to avoid interference with other macros that monitor my system clipboard to automatically reformat certain strings.
v3.0.0 Saturday, February 11, 2023
Now uses plutil command line to read the duplicated plist file.
BBEdit (and other text editors) are no longer a requirement.
2.0.0 (Friday, February 10, 2023)
Now uses AppleScript to open the copied plist file in the background
v1.1.0 Wednesday, March 23, 2022
Added some actions to show progress percentage in progess bar
v1.0.2 Saturday, March 05, 2022
Changed from AppleScript to native KM action to close BBEdit window
v1.0.1 Thursday, February 17, 2022
Adjusted the search portion to include the file path to rule out duplicate files (in different directories) from being improperly tagged.
v1.0.0 Wednesday, February 16, 2022
Initial macro