Command line search and open

General discussion related to "Everything".
Post Reply
jon_obvious
Posts: 3
Joined: Thu Oct 10, 2019 7:54 am

Command line search and open

Post by jon_obvious »

Hi

I can't figure out how to open a pdf once I search for it on the command line. Example:

Code: Select all

 -Command prompt-
R:\>es.exe z: *.pdf -highlight searched-file-name

Z:\searched-file-name-and-some-numbers.pdf
So now I want to open this .pdf file from the command line, how would I do that? Any suggestions would be appreciated.

Edit: To explain what I'm going for here.
I'm highlighting a string in a different program, then using autohotkey to trim the string, search it in everything, and opening the result. This involves a lot of "sleep" timers and doesn't always work out perfectly. I'm trying to do this without opening and focusing everything to avoid the sleeps so I want to try the Everything command line. Perhaps there is an easier way to approach this?
jon_obvious
Posts: 3
Joined: Thu Oct 10, 2019 7:54 am

Re: Command line search and open

Post by jon_obvious »

I noticed that everything has an "open file, close everything" hotkey so I used that instead. Saves a the step of installing es.exe and if the file isn't there, everything stays open to show that the file wasn't there. Autohotkey script:

Code: Select all

F8::				;open number as pdf
Clipboard :=""			;empty clipboard
Send, ^c 			;copy
ClipWait
StringTrimLeft, Clipboard, Clipboard, 3 ;trim first three
Send, {F3}			;open Everything hotkey, defined in Everything options
WinWaitActive, Everything, , 1
Send, ^v z: *.pdf 		;paste, filter Z drive and .pdf files
Send {Enter}
Send ^+{Enter} 			;open file and close Everything hotkey, defined in Everything options as crtl-shift-enter
Return
therube
Posts: 5060
Joined: Thu Sep 03, 2009 6:48 pm

Re: Command line search and open

Post by therube »

From a command line...

Code: Select all

ES.EXE   filename.ext   -export-txt  out.txt
SET /P   EVERYTHING_GO=<out.txt
CMD /C  "%EVERYTHING_GO%"
NotNull
Posts: 5517
Joined: Wed May 24, 2017 9:22 pm

Re: Command line search and open

Post by NotNull »

Very quick-and-dirty alternative (I do not recommend this):

Code: Select all

es.exe -n 1  z: *.pdf  searched-file-name -csv | cmd /k

Better way (from the commandline):

Code: Select all

for /f "usebackq delims=" %x in (`es -n 1 z: *.pdf  searched-file-name`) Do "%x"
Same command, but now in a script:

Code: Select all

for /f "usebackq delims=" %%x in (`es -n 1 z: *.pdf  searched-file-name`) Do "%%x"


But I think @jon_obvious already found a very nice solution himself.
Post Reply