I changed the Prompt action config (gear) to allow for multiple selections (which is what I want most of the time) but it does not work. One selection is fine. More than one and nothing happens when I press Enter. I know, based on some of your previous macros with prompts, that it should work.
to end up opening the selected file in default app, I added pause → keytroke Enter at the end. Is there a more elegant way of doing this ? I am NOT asking you to rewrite the macro yet again ! Just curious
I often use your macro in all kinds of situations, looking for files and calling up templates like the HoudahSpot Search Templates.
The only inconvenience is the 4.5 second delay (measured with a stopwatch) between the time the macro is triggered and the search box appears.
Is there anything that could be done to decrease the delay ?
thanks again !
You must be doing something time consuming on the front end of your macro, because the Prompt With List action is almost instant – unless you choke it with many thousands of items.
Can you post an example of a macro that is so slow?
I tested JM's macro, and it takes somewhere around 3 seconds to list 100 files on my old Mid-2010 17" 2.66 GHz Intel Core i7 MacBook Pro with only 8GB of memory.
Odd that it's taking longer on your newer hardware...
Even so – it's a pretty long pause to tolerate, unless you need to.
Load up this test macro.
Replace the path in the orange action with the 4 second folder on your system.
First and foremost, thanks very much for looking into this issue.
I downloaded your macro → changed the path as per your instructions → ran the macro → search window is immediately displayed. No perceptible delay which is fantastic.
Could you explain what you did ? Is it the shell script ?
thanks a million
JM is going beyond the default options for the Prompt With List action, and I think that's adding a little time to the macro.
He's also AppleScripting the Finder, and that's addling a little more time.
I haven't examined everything carefully for all possible bottlenecks...
My macro is using find in the shell and sed to maximize the speed of getting the file paths.
It's not quite as fancy and JM's, but the speed is worth it (to me).
I have the old 2010 MacBook Pro and a 2012 MacBook Air.
I desperately need some new hardware, but with the M1 Macs out now it's pointless to spend money – when I can get by for a while.
It does chafe though...
I'm thinking the 5K iMac M1 version will be where I want to go, but I'm not sure yet. It depends upon what Apple surprises us with and what their release schedule is.
I'm tempted to buy a M1 Mac Mini, but I'd have to have extra RAM, HD, and an external monitor – so the expense it too high right now.
I recently bought my mini. At the time, I looked at the M1 and was very disappointed. All kinds of limitations in RAM, external video support etc etc etc
I am very happy with the 2018 Mini.
Although you know much better, I like the fact that you can add RAM, external video card, external monitor etc which I can do gradually as opportunities arise.
You have to get a desktop because laptops are bad for your posture and consequently your back.
So sorry you have to live with 2010 and 2012 models.
My original macro and script was more focused on flexibility than on speed.
The updated ver 2.1 now uses AppleScript System Events to build the list files, resulting on a list of, for example, 211 files in only 0.23 sec:
Sorry for the slow version. It is now much faster. See above.
It now takes only 0.23 sec AFTER you select the target folder.
Chris, the script is much simplified now, uses System Events, and should be fast even on your old MBP. It runs in 0.23 sec on my 2019 iMac. Please let me know if it is still slow for you.
@ronald and @ccstone, there is a disabled Action that will display the elapsed time if you wish to time it:
Sorry, I had not tested the macro correctly. The search window and results are fine, but if I click on a file, nothing happens. I tried in a few different directories
with the new script, the delay is down to 0.3 sec on my mini, which is perfect. thanks very much.
In addition to searching for files, I use it to search houdahspot search templates which is great.
trying to figure out if I can search DevonThink smartgroups which require a lot of clicking.
But – you haven't eliminated invisible files, so .DS_Store files are showing up (and potentially others).
Simpler:
--------------------------------------------------------
# Whose-Clause filtering is slow as file numbers increase.
--------------------------------------------------------
# set targetFolderPath to "~/test_directory/Many_Files_100/"
set targetFolderPath to "~/test_directory/Many_Files_500/"
tell application "System Events"
set filePathList to POSIX path of files of disk item targetFolderPath whose visible is true
end tell
# 100 files --> 0.44 seconds
# 500 files --> 10.75 seconds
Much Faster:
--------------------------------------------------------
# Brute-force text list filtering is much faster.
--------------------------------------------------------
# set targetFolderPath to "~/test_directory/Many_Files_100/"
set targetFolderPath to "~/test_directory/Many_Files_500/"
tell application "System Events"
set filePathList to POSIX path of files of disk item targetFolderPath
end tell
set AppleScript's text item delimiters to "/"
repeat with i in filePathList
if i contains "/." then
set contents of i to 0
else
set iContents to contents of i
set contents of i to iContents & "__" & (last text item of iContents)
end if
end repeat
set AppleScript's text item delimiters to linefeed
set filePathList to text of filePathList as text
# 100 files --> 0.036
# 500 files --> 0.075
--------------------------------------------------------