Command line search for word or phrase in files

General discussion related to "Everything".
Post Reply
Marceepoo
Posts: 8
Joined: Sat Jan 05, 2019 7:48 pm

Command line search for word or phrase in files

Post by Marceepoo » Fri Feb 21, 2020 9:36 pm

Could someone give me an example of a Command line search for a word or phrase in files?
The following search produces an Everything window that shows all files containing the string "smith" in the filename:

Code: Select all

"C:\Program Files\Everything\Everything.exe" -search "smith" -newwindow
But I want to create a command line that searches for the word "smith" in the body/content of files ending in .txt, .asp, .htm, .html, .doc, .docx, etc. --- If that is possible, how would I code that search?

Thank you for any help, even if it's only to some reference page.

Marceepoo

void
Site Admin
Posts: 6678
Joined: Fri Oct 16, 2009 11:31 pm

Re: Command line search for word or phrase in files

Post by void » Sat Feb 22, 2020 8:08 am

Please try the following search:

"C:\Program Files\Everything\Everything.exe" -search "ext:txt;asp;htm;html;doc;docx content:smith" -newwindow


If you need to escape double quotes, use triple double quotes, for example:

"C:\Program Files\Everything\Everything.exe" -search "ext:txt;asp;htm;html;doc;docx content:"""to be or not to be"""" -newwindow


-search
Command line option notes
Search syntax

Marceepoo
Posts: 8
Joined: Sat Jan 05, 2019 7:48 pm

Re: Command line search for word or phrase in files

Post by Marceepoo » Fri Mar 19, 2021 9:33 pm

Thank you, .... more than a little belatedly.

The following search works just fine:

Code: Select all

"C:\Program Files\Everything\Everything.exe" -path "F:\K\Smith John" -search "ext:txt;asp;htm;html;doc;docx;pdf content:guyante" -newwindow
But Everything freezes when I try to run the same search against the much larger directory, to wit, "F:\K" -- which has a little less than 1 TB of files/data.

I am guessing that the GUI imposes a lot of overhead, and so I tried my first stab at using ES.exe, and constrained myself to a smaller directory, to work out the kinks, but I didn't get very far. The following line of code triggered the error "unknown switch":

Code: Select all

"E:\Apps\Everything\ES-1.1.0.18\es.exe" -path "F:\K\Smith John" -search "ext:txt;asp;htm;html;doc;docx;pdf content:guyante" -export-efu "E:\Zmani\Logging\Guyante001.efu"
The following line, without the "-search ", did not trigger an error, but the file that was created "Guyante.efu" was empty:

Code: Select all

"E:\Apps\Everything\ES-1.1.0.18\es.exe" -path "F:\K\Smith John" "ext:txt;asp;htm;html;doc;docx;pdf content:guyante" -export-efu "E:\Zmani\Logging\Guyante001.efu"
What am I doing wrong? Also, is there a command line switch to create a log file?

Thank you so much for your help.

Marc

void
Site Admin
Posts: 6678
Joined: Fri Oct 16, 2009 11:31 pm

Re: Command line search for word or phrase in files

Post by void » Sat Mar 20, 2021 1:59 am

I think you are confusing the command line options for Everything.exe with the command line options for ES?

-path and -search are for Everything.exe

Please try the following ES search:
"E:\Apps\Everything\ES-1.1.0.18\es.exe" "F:\K\Smith John" ext:txt;asp;htm;html;doc;docx;pdf content:guyante -export-efu "E:\Zmani\Logging\Guyante001.efu"

Any parameters you pass to ES are treated as your search query, basically the same as typing in the search into the Everything GUI.

To view IPC requests in Everything, please try the debug console. IPC requests are shown in Cyan color.

Marceepoo
Posts: 8
Joined: Sat Jan 05, 2019 7:48 pm

Re: Command line search for word or phrase in files

Post by Marceepoo » Mon Mar 29, 2021 10:40 pm

Here's the command line I tried:

Code: Select all

"E:\Apps\Everything\ES-1.1.0.18\es.exe" "E:\K\Rose Rita" ext:txt;asp;htm;html;doc;docx;pdf content:guyante -export-efu "E:\Zmani\Logging\Guyante001.efu"
Immediately after I hit the return key, I get a new command prompt, as shown in the following image, and the "Guyante001.efu" file is never created:
Image
The image is now showing up in the preview, so I'm posting the image's url here:
https://drive.google.com/file/d/1Ge92PO ... sp=sharing
What am I doing wrong?

void
Site Admin
Posts: 6678
Joined: Fri Oct 16, 2009 11:31 pm

Re: Command line search for word or phrase in files

Post by void » Tue Mar 30, 2021 1:04 am

Does the path: E:\Zmani\Logging exist?

-If not, please try creating this folder before rerunning ES with the same command.

Everything might be performing a rebuild, try the following command:

Code: Select all

"E:\Apps\Everything\ES-1.1.0.18\es.exe" "E:\K\Rose Rita" ext:txt;asp;htm;html;doc;docx;pdf content:guyante -export-efu "E:\Zmani\Logging\Guyante001.efu" -timeout 300000
Does the following return any results:

Code: Select all

"E:\Apps\Everything\ES-1.1.0.18\es.exe" "E:\K\Rose Rita" ext:txt;asp;htm;html;doc;docx;pdf

Marceepoo
Posts: 8
Joined: Sat Jan 05, 2019 7:48 pm

Re: Command line search for word or phrase in files

Post by Marceepoo » Tue Mar 30, 2021 8:32 pm

I verified that there is a path: E:\Zmani\Logging

I'm not running everything as a service. My bootup batch file contains the following line to start everything:

Code: Select all

START "Everything" "C:\Program Files\Everything\Everything.exe"
I put the following lines of code in a batch file named: 2021-03-29__hakol_aaa.cmd and I ran it in a cmd window under Win10 with administrator privileges.

Code: Select all

set _DateTime=%DATE:~10,4%-%DATE:~4,2%-%DATE:~7,2%_%time:~0,2%_%time:~3,2%_%time:~6,2%

"E:\Apps\Everything\ES-1.1.0.18\es.exe" "E:\K\Rose Rita" ext:txt;asp;htm;html;doc;docx;pdf content:guyante -export-efu "E:\Zmani\Logging\%_DateTime%_Guyante001.efu" -timeout 300000

"E:\Apps\Everything\ES-1.1.0.18\es.exe" "E:\K\Rose Rita" ext:txt;asp;htm;html;doc;docx;pdf
The .efu file that gets created is always empty except for the headers.
If I run each of the lines (in the batch file) individually in a cmd window, I immediately get a cmd prompt after I enter the line of code; there is no delay.

Too much info? Is there something else I should tell you?
THANK YOU so much for working with me. Much appreciated.

void
Site Admin
Posts: 6678
Joined: Fri Oct 16, 2009 11:31 pm

Re: Command line search for word or phrase in files

Post by void » Wed Mar 31, 2021 8:49 am

If I run each of the lines (in the batch file) individually in a cmd window, I immediately get a cmd prompt after I enter the line of code; there is no delay.
This means Everything is not finding any results.

What is returned from the following call:

"E:\Apps\Everything\ES-1.1.0.18\es.exe" -get-result-count

Post Reply