open file or run program when only 1 result

Have a suggestion for "Everything"? Please post it here.
Post Reply
dele
Posts: 10
Joined: Sat Feb 16, 2013 8:57 am

open file or run program when only 1 result

Post by dele »

I use Everything (since years) very often each day and for the most used searches I have defined bookmarks; some of them with macro. Very often the result is just one file or one program, which I usually want to open or run immediately.
Would it be possible to add a search function like autoopen or autorun or something comparable, telling Everything to open a file or run a program, when there is only one entry in the result list?

respectfully and with kind regards
dele
Posts: 10
Joined: Sat Feb 16, 2013 8:57 am

Re: open file or run program when only 1 result

Post by dele »

I happend to detect this suggestion viewtopic.php?f=4&t=4992, where void answered:
I have put on my TODO list to add commands to execute result 1 through 12.
Thank you for your suggestion.
If I understood correctly, this would also be a solution to my question/suggestion.
void
Developer
Posts: 16735
Joined: Fri Oct 16, 2009 11:31 pm

Re: open file or run program when only 1 result

Post by void »

Thank you for your feedback dele,

I recommend setting the run count for your programs to a very high number:
  • Search for your program, for example calc.exe:
    C:\Windows\System32\calc.exe
  • Right click calc.exe and click Set Run Count...
  • Set the run count to: 1000 and click OK.
Now all your need to do is type in calc and press ENTER twice.
The first ENTER key press will select the result with the highest run count.

Note: Please make sure Run History is enabled under Tools -> Options -> History.



The /open 0 bookmark trick should also work.
However, you will need to press a keyboard shortcut to active the bookmark.
wason92
Posts: 8
Joined: Tue May 10, 2022 1:35 pm

Re: open file or run program when only 1 result

Post by wason92 »

You could do this programmatically using es.
https://www.voidtools.com/support/every ... interface/

Code: Select all

	es -n 1 everything64.exe
returns
	"C:\Program Files\Everything 1.5a\Everything64.exe"
so you can do 
	for /f "tokens=*" %%i in ('es -n 1 everything64.exe') do "%%i"
This loop takes what es returns surrounds it with quotes and executes it.

es doesn't take bookmarks, so you would need to write a bat/cmd file for each bookmark, save them wherever you want and then you can get what you want with just a double click.

If you're comfortable with batch scripts you can look at this
It's a script that will show you the first 10 results for something, then let you choose which one to run
like this https://streamable.com/gc2l2w

if you replace '%1' with your search query, this would open cmd, and ask you to pick a result to run, or run the first if only 1 result.

Code: Select all

@echo off
setlocal enabledelayedexpansion enableextensions
set i=0
set st=es -n 10
for /f "tokens=*" %%a in ('%st% %1') do (
 set /a i=!i!+1
 set results[!i!]=%%a
 echo !i!	%%a
)
set c=1
if %i% gtr 1 (
FOR /L %%c IN (1,1,%i%) DO (
  set c=!c!%%c
)
set /P c="run _ "||set c=1
)
"!results[%c%]!"

Post Reply