How do i correctly escape spaces when passing title:"foo bar" to es.exe (CLI)?

If you are experiencing problems with "Everything", post here for assistance.
Post Reply
waffeln
Posts: 25
Joined: Wed Dec 29, 2021 11:35 am

How do i correctly escape spaces when passing title:"foo bar" to es.exe (CLI)?

Post by waffeln »

When i run

Code: Select all

es.exe title:"foo bar"
i will get 0 results unlike in the Everything GUI. I'm pretty sure it's related to the way i escape the parameter. Am i doing something wrong?
void
Developer
Posts: 16683
Joined: Fri Oct 16, 2009 11:31 pm

Re: How do i correctly escape spaces when passing title:"foo bar" to es.exe (CLI)?

Post by void »

The following is correct:

Code: Select all

es.exe title:"foo bar"
This search can take a long time.
Does ES return 0 results immediately?

Combine with other search functions for the best results:

Code: Select all

es.exe ext:mp3;flac "D:\Music Albums\" title:"foo bar"

Are you using multiple instances?

Does the following ES call find any results:

Code: Select all

exact:"c:\program files"

Are you calling es instead of es.exe?
Are you using an es.bat to call es.exe? -please make sure you expand all arguments with %*
waffeln
Posts: 25
Joined: Wed Dec 29, 2021 11:35 am

Re: How do i correctly escape spaces when passing title:"foo bar" to es.exe (CLI)?

Post by waffeln »

  • This search can take a long time.
    I know, i ommitted the other parameters that i use. The command was just an example.
    Here's a real query in Powershell:

    Code: Select all

    PS C:\Users\Function> es.exe -path D:/Library upgrade want u
    D:\Library\Gentlemens Club\Want U\02 Gentlemens Club, Upgrade - Want U (Upgrade Remix).mp3
    D:\Library\Gentlemens Club\Want U\02 Gentlemens Club-Upgrade - Want U (Upgrade Remix).mp3
    D:\Library\Gentlemens Club\Want U\1-02 Gentlemens Club, Upgrade - Want U (Upgrade Remix).mp3
    PS C:\Users\Function> es.exe -path D:/Library upgrade want u title:"Want U (Upgrade Remix)"
    PS C:\Users\Function>
  • Does ES return 0 results immediately?
    Yes
  • Are you using multiple instances?
    No
  • Are you calling es instead of es.exe?
    There is no difference between the two. es gets resolved to es.exe and there is no es.bat file on my system.
  • please make sure you expand all arguments with %*
    I'm sorry but i don't know how to do that.
  • Does the following ES call find any results [...]
    It works in the Everything GUI, but not with es.exe. (No results, query takes less than a second)
horst.epp
Posts: 1443
Joined: Fri Apr 04, 2014 3:24 pm

Re: How do i correctly escape spaces when passing title:"foo bar" to es.exe (CLI)?

Post by horst.epp »

Do you have installed the Everything Lite version ?
waffeln
Posts: 25
Joined: Wed Dec 29, 2021 11:35 am

Re: How do i correctly escape spaces when passing title:"foo bar" to es.exe (CLI)?

Post by waffeln »

horst.epp wrote: Tue Mar 08, 2022 12:17 pm Do you have installed the Everything Lite version ?
No, the "About" says "Everything", "Version 1.4.1.1015 (x64)".

I also noticed that es.exe -h seems to exit with error level 6, which confused me in some of my testing (Node.js's child_process module will throw an error when it gets any error level that's not 0).

Edit 1: This is by design because -h is not a valid flag. The exit codes are documented here.

Edit 2: In the help output, -h is indeed documented as a valid flag, so i think this might be an oversight. es.exe -h should exit with code 0.
waffeln
Posts: 25
Joined: Wed Dec 29, 2021 11:35 am

Re: How do i correctly escape spaces when passing title:"foo bar" to es.exe (CLI)?

Post by waffeln »

I've run into another issue when i try to run es.exe using Node.js, but this time it works in Powershell but doesn't when i use execFile.
Ofcourse one might immediately blame my code or Node.js for this, but i honestly have no idea where to even start to debug this.

The search query: "Klax" "Charli Brix"
This search query works in Everything GUI and the es.exe CLI (both 1 result as expected), but it doesn't work when i call it using execFile:

Code: Select all

require("child_process").execFile("es.exe", [`"Klax"`, `"Charli Brix"`], (err, stdout) => console.log(stdout)) // empty string
Args must be passed as a string array to this native function.
Is there any flag or debug version that will make es.exe echo back the query that it received? I might get a better idea of what's happening under the hood.
void
Developer
Posts: 16683
Joined: Fri Oct 16, 2009 11:31 pm

Re: How do i correctly escape spaces when passing title:"foo bar" to es.exe (CLI)?

Post by void »

Powershell mangles double quotes.
es.exe title:"foo bar" is changed to: es.exe "title:foo bar"
This will unfortunately escape the title: function call.

Please try the following:

Code: Select all

es.exe title:'"foo bar"'

Is there any flag or debug version that will make es.exe echo back the query that it received?
To enable Everything Debug Mode:
  • In Everything, type in the following search and press ENTER:
    /debug
  • A debug console is shown.
  • IPC requests are shown in Cyan color.


To close the debug console:
  • In Everything, type in the following search and press ENTER:
    /debug
waffeln
Posts: 25
Joined: Wed Dec 29, 2021 11:35 am

Re: How do i correctly escape spaces when passing title:"foo bar" to es.exe (CLI)?

Post by waffeln »

It's kinda confusing that a shell is involved here because the documentation says that execFile doesn't spawn a shell by default.

Anyway, you've helped me out a ton! The single quote "escaping" if it can be called that worked, and also the debug mode helped me figure out what's going wrong with my code. execFile wraps arguments in quotes that contain a space, so Everything received something like search '"\"Klax\"" "\"Charli Brix\""' instead of search '"Klax" "Charli Brix"'. I'll just not wrap args that i don't want to split in quotes if they contain a space.

This software is so incredible honestly, thank you and all the other contributors so much!

Edit: I got into more issues with the single quote escaping when the title contains spaces and the args gets wrapped by double quotes again - i finally came across this answer on stackoverflow which basically solved all my quote problems!! It's now much easier for me to talk to es.exe because i can just dump all args into a single string and it will be used as-is. I'm so happy!
Post Reply