Counting Files Whose Names Share the Same Number

FWIW you probably know that once you have a Keyboard Maestro variable in the form of a JSON object string, you can loop through its keys:

collection:JSON Keys [Keyboard Maestro Wiki]

Filename prefix frequencies (and list of prefixes found).kmmacros (11.4 KB)

1 Like

You could also look at my first answer, which also did the JSON/dictionary thing, but using Perl instead of JavaScript.

1 Like

Excellent, I have some very strong options thanks to you all!

This should work, the output was just "arrays" of value, frequency that can be easily accessed in KM, and is easier than using a dictionary (always remembering that I boobed with the original number extraction, so use @drdrang's or @ccstone's corrected versions). That's assuming that the letter doesn't matter, ie you don't want to do different actions for 3z and 3y.

If it isn't working, post a sample macro that demonstrates the error.

1 Like

Hey Nicolas,

Remember that you can use the native Keyboard Maestro Search using Regular Expression action to extract text to variables.

-Chris

1 Like