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.
Command Line Tool ES
Re: Command Line Tool ES
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.
Then you know that there was an empty result.
Whats the problem to detect a 0 lenght results file.
-
- Posts: 7
- Joined: Fri Jan 26, 2018 8:38 pm
Re: Command Line Tool ES
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.
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.
Re: Command Line Tool ES
There are a couple of options.
What and how do you run it currently? Shortcut? CMD prompt? batchfile? PowerShell script? Other?
What and how do you run it currently? Shortcut? CMD prompt? batchfile? PowerShell script? Other?
-
- Posts: 7
- Joined: Fri Jan 26, 2018 8:38 pm
Re: Command Line Tool ES
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"
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"
Re: Command Line Tool ES
Try this:
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"
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
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"
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)\"> """
Re: Command Line Tool ES
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="
-
- Posts: 7
- Joined: Fri Jan 26, 2018 8:38 pm
Re: Command Line Tool ES
implemented the first solution and works like a charm. thank you!