With the ES Comand line tool, how do I use '-' as part of the search?

Discussion related to "Everything" 1.5 Alpha.
Post Reply
Ralf_Reddings
Posts: 120
Joined: Fri Mar 24, 2023 4:53 pm

With the ES Comand line tool, how do I use '-' as part of the search?

Post by Ralf_Reddings »

For example, if I had a file with a dash in its name, cat - 5.png, I have tried the following calls to find it:

Code: Select all

ES -match-path -max-results 5 cat - 5 .png
ES -Gmatch-path -max-results 5 "cat - 5" .png
ES -match-path -max-results 5 cat "-" 5 .png
ES -match-path -max-results 5 cat '-' 5 .png
ES -match-path -max-results 5 cat '^-' 5 .png
But each call fails with an error, with the help for ES being printed. I am using latest Everything 1.5

Thanks for any help
void
Developer
Posts: 16759
Joined: Fri Oct 16, 2009 11:31 pm

Re: With the ES Comand line tool, how do I use '-' as part of the search?

Post by void »

Powershell is removing the double quotes.

ES uses double quotes to escape command line options.



Please try the following with powershell:

Code: Select all

ES -match-path -max-results 5 cat '"-"' 5 .png
ES -match-path -max-results 5 "cat - 5" .png


I have put on my TODO list to treat a single dash (-) as literal.
Ralf_Reddings
Posts: 120
Joined: Fri Mar 24, 2023 4:53 pm

Re: With the ES Comand line tool, how do I use '-' as part of the search?

Post by Ralf_Reddings »

Thanks for the answer void. I tried
ES -match-path -max-results 5 cat '"-"' 5 .png
but it did not work. I can confirm that
ES -match-path -max-results 5 "cat [list]5" .png
worked but I think this will prove difficult for me to use in my PowerShell module (7.4)[/list]

I followed your example and discovered the following also work:

Code: Select all

ES xx "" - "
ES xx '- '
ES xx ' -'
ES xx "- "
ES xx " -"
Looking forward to the much anticipated ES update :)
therube
Posts: 4979
Joined: Thu Sep 03, 2009 6:48 pm

Re: With the ES Comand line tool, how do I use '-' as part of the search?

Post by therube »

Why didn't this one work for you (from a CMD prompt)?
ES -match-path -max-results 5 cat "-" 5 .png
It should, shouldn't it?
Ralf_Reddings
Posts: 120
Joined: Fri Mar 24, 2023 4:53 pm

Re: With the ES Comand line tool, how do I use '-' as part of the search?

Post by Ralf_Reddings »

Okay, I take back my words. I have yet to find a complete solution for using "-" as part of the search. If there are three files like so:

Code: Select all

C:\dogs\dogs [list]man.png[/list]
C:\dogs\dogs -man.png`
C:\dogs\dogs[list]man.png`[/list]
ES -match-path dogs ' -' man
finds:

Code: Select all

C:\dogs\dogs - man.png
C:\dogs\dogs -man.png`
but does not find
C:\dogs\dogs -man.png

On the other hand
ES -match-path dogs '- ' man
finds:

Code: Select all

C:\dogs\dogs - man.png
C:\dogs\dogs- man.png
but does not find
C:\dogs\dogs -man.png


I also tried
ES -match-path dogs `<'- '`|' -'`>man
("`" is for Powershell escaping ) and nothing gets returned.

Perhaps I can create a bookmark, use its macro to insert a literal
-
in the ES search, I will try that and see.

Also does anyone know if ES supports the 1.5 pre-processor features? Perhaps wrapping a pre-processor replacement into a bookmark macro might do it. I have never used them but this might be an ideal use case.

@therube
I am targeting PowerShell, I really would not know where to begin with CMD (I never touch it...)
void
Developer
Posts: 16759
Joined: Fri Oct 16, 2009 11:31 pm

Re: With the ES Comand line tool, how do I use '-' as part of the search?

Post by void »

ES-1.1.0.28
  • Treat a single - as literal instead of as an invalid switch.


Please also try the following to escape a dash (-)

"&#45:"
-or-
"&#x2d:"

Character Entities



Please also try the following to escape a dash (-)
(easier to do from the command line / powershell)

[char:45]
-or-
[char:0x2d]

[char:]
Ralf_Reddings
Posts: 120
Joined: Fri Mar 24, 2023 4:53 pm

Re: With the ES Comand line tool, how do I use '-' as part of the search?

Post by Ralf_Reddings »

This was a life saver update. Thank you void!
Post Reply