Command Line Tool ES

If you are experiencing problems with "Everything", post here for assistance.
Post Reply
irinaonline
Posts: 7
Joined: Fri Jan 26, 2018 8:38 pm

Command Line Tool ES

Post by irinaonline »

How can I omit the creation of a file, if the search result is empty?

The parameter -hide-empty-search-results doesn't do the trick.
horst.epp
Posts: 1443
Joined: Fri Apr 04, 2014 3:24 pm

Re: Command Line Tool ES

Post by horst.epp »

Use the parameter -no-result-error
Then you know that there was an empty result.
Whats the problem to detect a 0 lenght results file.
irinaonline
Posts: 7
Joined: Fri Jan 26, 2018 8:38 pm

Re: Command Line Tool ES

Post by irinaonline »

It would fit better in my workflow if the file wouldn't be created if the search result is empty.

I scan periodically filesets with a specific pattern and save it in a .csv.

This csv's are imported in a spreadsheet to monitor changes, etc.
NotNull
Posts: 5458
Joined: Wed May 24, 2017 9:22 pm

Re: Command Line Tool ES

Post by NotNull »

There are a couple of options.
What and how do you run it currently? Shortcut? CMD prompt? batchfile? PowerShell script? Other?
irinaonline
Posts: 7
Joined: Fri Jan 26, 2018 8:38 pm

Re: Command Line Tool ES

Post by irinaonline »

batch file

one example:

echo Creating 0IL0.csv ...
C:\Users\Leopold\Dropbox\Essentials\ES-1.1.0.23\es.exe -hide-empty-search-results -match-path -p -date-recently-changed -date-modified -name -size -path-column -extension -date-created -date-accessed -attributes -run-count -date-run -file-list-file-name -sort path-ascending /a-d .jpg C:^\ ^\Users^\Leopold^\ !^<^\AppData^\^|"^\- "^|^\-^|" - GPC "^|^\Essentials^|^\Public^|^\iTunes^|^\Install^|^\Music^|"Google Sites^\"^|^\schmallegger2^|^\AC^\^> !0ML 0IL0 -export-csv "C:\Users\Leopold\GD\- Inbox\0IL0.csv"
NotNull
Posts: 5458
Joined: Wed May 24, 2017 9:22 pm

Re: Command Line Tool ES

Post by NotNull »

Try this:

Code: Select all

C:\Users\Leopold\Dropbox\Essentials\ES-1.1.0.23\es.exe -noresulterror -hide-empty-search-results -match-path -p -date-recently-changed -date-modified -name -size -path-column -extension -date-created -date-accessed -attributes -run-count -date-run -file-list-file-name -sort path-ascending /a-d .jpg C:^\ ^\Users^\Leopold^\ !^<^\AppData^\^|"^\- "^|^\-^|" - GPC "^|^\Essentials^|^\Public^|^\iTunes^|^\Install^|^\Music^|"Google Sites^\"^|^\schmallegger2^|^\AC^\^> !0ML 0IL0 -export-csv "C:\Users\Leopold\GD\- Inbox\0IL0.csv" 2>nul|| del "C:\Users\Leopold\GD\- Inbox\0IL0.csv"
The "interesting" parts:
es.exe -noresulterror [your original command] "C:\Users\Leopold\GD\- Inbox\0IL0.csv" 2>nul || del "C:\Users\Leopold\GD\- Inbox\0IL0.csv"
  • -noresulterror :
    generates an errorlevel if there are no files found
  • || :
    executes the following command *only* if the previous command (the ES command-line) exits with an errorlevel not equal to 0.
    Meaning that if zero files were found, the created (empty) csv-file will be deleted.
  • 2>nul :
    Suppresses the errormessage Everything would show ("Error 9: No results found.")

An alternative would be to run ES.exe -getresultcount [your original command, without exporting results] first.
When that reports 0 results, don't run your original query.


I didn't look closely at your command, but I suspect a lot of escaping ^'s can be prevented by using """.
A simpler example, just for the syntax to get you going if needed:

Code: Select all

es.exe """ <"c:\program files\"> |  <"c:\Program Files (x86)\">  """
NotNull
Posts: 5458
Joined: Wed May 24, 2017 9:22 pm

Re: Command Line Tool ES

Post by NotNull »

NotNull wrote: Fri Apr 15, 2022 10:02 pm An alternative would be to run ES.exe -getresultcount [your original command, without exporting results] first.
When that reports 0 results, don't run your original query.
Well, it would be useful if I posted the code for that ... Sorry.

Code: Select all

:: Get #results to file
   C:\Users\Leopold\Dropbox\Essentials\ES-1.1.0.23\es.exe -hide-empty-search-results -match-path -p -date-recently-changed -date-modified -name -size -path-column -extension -date-created -date-accessed -attributes -run-count -date-run -file-list-file-name -sort path-ascending /a-d .jpg C:^\ ^\Users^\Leopold^\ !^<^\AppData^\^|"^\- "^|^\-^|" - GPC "^|^\Essentials^|^\Public^|^\iTunes^|^\Install^|^\Music^|"Google Sites^\"^|^\schmallegger2^|^\AC^\^> !0ML 0IL0 -getresultcount>"%temp%\count.deleteme"

:: Put #results in variable
   set /p count=<"%temp%\count.deleteme"

:: Generate CSV if there are results
   If NOT "%count%"=="0"   C:\Users\Leopold\Dropbox\Essentials\ES-1.1.0.23\es.exe -hide-empty-search-results -match-path -p -date-recently-changed -date-modified -name -size -path-column -extension -date-created -date-accessed -attributes -run-count -date-run -file-list-file-name -sort path-ascending /a-d .jpg C:^\ ^\Users^\Leopold^\ !^<^\AppData^\^|"^\- "^|^\-^|" - GPC "^|^\Essentials^|^\Public^|^\iTunes^|^\Install^|^\Music^|"Google Sites^\"^|^\schmallegger2^|^\AC^\^> !0ML 0IL0 -export-csv "C:\Users\Leopold\GD\- Inbox\0IL0.csv"

:: Cleanup
   del "%temp%\count.deleteme"
   set "count="
irinaonline
Posts: 7
Joined: Fri Jan 26, 2018 8:38 pm

Re: Command Line Tool ES

Post by irinaonline »

implemented the first solution and works like a charm. thank you!
Post Reply