Hey @peternlewis, I see some odd behavior using the %FinderSelections% token after upgrading to KM11. When I have a large number of items selected in Finder, the token takes a long time to populate. Once I have around 284 or more items selected, it doesn’t seem to return anything at all.
I’ve attached a screen recording where you can see me initially selecting three items and triggering a simple macro to filter the token to a variable, and showing the results in an alert action (see attached macro screenshot). The second portion shows me selecting 247 items and it shows accurate results. In the final portion, I select 812 items, and the token ends up empty, resulting in “1” after filtering it.
I restarted the Engine and Editor and the issue persists. I'll try rebooting and post if that fixes it.
I can get the token to return file paths up to 280 characters in length, but if I try to use the token on multiple files, I get no data from that token. Any attempt to get multiple files out of that token returns empty space. I can't replicate your macro giving me more than one line count. There's something oddly similar but oddly different between our tests.
Sorry, forgot to include that. Problem persists after a complete reboot.
Model Name : MacBook Pro
Model Identifier : Mac14,9
Model Number : Z17G002HSLL/A
Total Number of Cores : 10 (6 performance and 4 efficiency)
Memory : 16 GB
System Firmware Version : 10151.1.1
OS Loader Version : 8422.141.2
Chipset Model : Apple M2 Pro
Total Number of Cores : 16
System Version : macOS 13.6 (22G120)
Kernel Version : Darwin 22.6.0
System Integrity Protection : Enabled
Time since boot : 3 minutes, 50 seconds
I don't know what @Airy is doing, but I think your issue is that you are running up against the 0.5s token text time. I changed it so tokens could not take longer than 0.5s to respond (mostly to deal with JavaScript tokens taking an unlimited amount of time). So I suspect when the number of selected entries gets large enough it eventually takes more than 0.5s to respond and the token gives up and returns nothing.
I might extend this a little, and maybe add a configuration in for how long it takes.
You could probably determine this by using the SECONDS function to determine roughly how long the action takes to execute. Ideally just a:
Hey Peter, thanks for the detailed explanation. This does appear to be the case. Running my demo macro below a dozen or so times, it appears that anytime the set variable action takes longer than .5 seconds, it returns “1” instead of the actual number of Finder items. Not a big deal, as I don’t imagine there are a lot of users that execute macros on such a large number of Finder items, but I have a couple of macros that do, (for instance: my macro to tag files that are used in KM macros, so the ability to adjust the timeout would be nice.
I've increased the timeout to 0.9 seconds for the token, and made it configurable with a hidden preference, but realistically, if you want to deal with a large number of files, then the token is probably not the right choice - tokens have no control and are expected to be more or less instant.