ES, how to ESCape | passed to a BAT file?

General discussion related to "Everything".
Post Reply
therube
Posts: 4610
Joined: Thu Sep 03, 2009 6:48 pm

ES, how to ESCape | passed to a BAT file?

Post by therube »

ES, how to ESCape a | (pipe) passed to a BAT file?

heh.

Say I've got something like go.bat.
How do I quote "" or do I quote "" in the batch file such that my escape | is passed as wanted to ES?
Or | can I quote from the command line to get what I want?

C:\> GO.bat xxx.mp3 ^| yyy.mp3


go.bat:

Code: Select all

:: xxx.mp3 ^| yyy.mp3

@echo off
:: echo NOQUOTE: %*
:: pause
echo   QUOTE: "%*"
pause


es.ex2  -instance 15  -name  -highlight  distinct:    %*
pause
goto end:


:end
echo hi
(I have a general dislike, heh, for Windows batch files, the command line shell in general.)
NotNull
Posts: 5260
Joined: Wed May 24, 2017 9:22 pm

Re: ES, how to ESCape | passed to a BAT file?

Post by NotNull »

If you are running GO.bat xxx.mp3 | yyy.mp3 from the (CMD) command-line, the | will already do its damage, so you need to escape the pipe somehow.
The first option is -- like you already showed -- to use ^| instead of | by itself.
The second option is to put the entire search between "" :
GO.bat "xxx.mp3 | yyy.mp3"
and in go.bat something like (untested):

Code: Select all

set parms=%*
set parms=%parms:|=^|%
es %parms%

But because of your dislike (escaping problematic chars can indeed give a headache), I would go the following route:
- Enable Allow literal operators in Everything (under Tools => Optiosn => Serach)
- Run GO.bat xxx.mp3 OR yyy.mp3
therube
Posts: 4610
Joined: Thu Sep 03, 2009 6:48 pm

Re: ES, how to ESCape | passed to a BAT file?

Post by therube »

Literal operators.
How ingenious :-).


(That said, while it "works", I still have some issues.)
therube
Posts: 4610
Joined: Thu Sep 03, 2009 6:48 pm

Re: ES, how to ESCape | passed to a BAT file?

Post by therube »

how to ESCape < and >

ES.exe abc < def OR ghi >

oh, abc AND def OR ghi, is not right
so, abc def OR abc ghi, while that may be right, that is not right ;-)
so, how to ESC < and >
(& as i write[right, wright] this, Lil Wayne is singing about Loud Pipes, & there are all kinds of *right* in that song)

why does

ES.exe abc def OR abc ghi audio: distinct:, work

when

SSSA.bat abc def OR abc ghi, does not work ?
(as in results are returned, but not expected results,
as in more then audio: turns up, like (audio).lnk

SSSA.bat:
es.ex2 -instance 15 -name -highlight distinct: audio: %*


SSSA2.bat:
es.ex2 -instance 15 -name -highlight distinct: audio: %* !.lnk


(I have a general dislike, heh, for Windows batch files, the command line shell in general.)
NotNull
Posts: 5260
Joined: Wed May 24, 2017 9:22 pm

Re: ES, how to ESCape | passed to a BAT file?

Post by NotNull »

Code: Select all

ES.exe
Without specifying a -instance option, this might run Everything 1.4 or 1.5. depending on the instance setting in ES.ini,
Check the Operator precedence in both ( either OR>AND or AND>OR)
This will have influence on the results you see.

therube wrote: Mon Jan 09, 2023 5:07 pm how to ESCape < and >
Does this work for you? (untested)

Code: Select all

es.exe """ abc < def OR ghi OR "search term with a space" >"""
(the "search term with a space" was added because I suspect that will be your next question :D)
void
Developer
Posts: 15352
Joined: Fri Oct 16, 2009 11:31 pm

Re: ES, how to ESCape | passed to a BAT file?

Post by void »

ES will pass quotes to Everything.

Use ^ to escape special characters ( & | > < ^ )

Code: Select all

ES.exe abc ^< def ^| ghi ^>


There's also the literal operator: or:

Code: Select all

ES.exe abc ^< def or: ghi ^>
(you don't need to enable literal operators for this one)



In the next alpha update I'll also add group-start: and group-end:

Code: Select all

ES.exe abc group-start: def or: ghi group-end:
^ = escape is probably the easiest to remember.
therube
Posts: 4610
Joined: Thu Sep 03, 2009 6:48 pm

Re: ES, how to ESCape | passed to a BAT file?

Post by therube »

rambling... some batch files:

SSS.bat:

Code: Select all

@echo off
es.ex2  -instance 15  -name  -highlight  distinct:  %*
es.ex2  -instance 15                              distinct:  %*  -double-quote -n 1 > c:\out\sssGO.TXT
@es.ex2 -instance 15                                         %*  -export-efu  c:\out\sssGO.efu  !\Windows\Recent  file:
SSSL.bat:

Code: Select all

:: SSSL SjB 12-18-2022   Open an ES File List

:: SSS, but an entire File List rather then a singular file (as with sssgo.TXT)
:: this opens in a "static" version of Everything (rather then in the current...)


@echo off
start /B  cmd /C   "C:\DEV\Locate\15.filelist\Everything.exe"   -instance FILELIST  -read-only -no-db  -filelist C:\OUT\sssGO.efu
PAUSE
ES.bat:

Code: Select all

@es.ex2 -instance 15  %*
@es.ex2 -instance 15                                        %*  -double-quote -n 1  > c:\out\sssGO.TXT
@es.ex2 -instance 15                                        %*  -export-efu c:\out\sssGO.efu  !\Windows\Recent  file:
SSSE.bat:

Code: Select all

:: SSSE SjB 12-18-2022

:: SSS, but an ES search (rather then ...)
:: with the intent that it is a PROGRAM rather then something else
:: so the START should EXECUTE the program, rather then ...


@echo off
echo About to EXECUTE:
cat c:/out/sssgo.txt
pause

for /f "tokens=*" %%i in (c:\out\sssgo.txt) do        start /B CMD /C                        %%i
SSSG.bat:

Code: Select all

:: this opens a file in MPlayer (media player)

@echo off
for /f "tokens=*" %%i in (c:\out\sssgo.txt) do cmd /c start C:\WLIB\PLAYERS\MPlayer\MPUI.exe %%i
(ex.ex2 is simply es.exe, renamed.)
therube
Posts: 4610
Joined: Thu Sep 03, 2009 6:48 pm

Re: ES, how to ESCape | passed to a BAT file?

Post by therube »

opening an .efu, directly
does not 'Show highlighted search term'
even if the .efu was created based on
a particular search term

ES.exe ww:red OR ww:blue > cats.efu && Everything -filelist cats.efu
any way to "pre-set" Search as ww:red | ww:blue ?

oh...

SSS -> SET xES=%*
SSSl -> Everything -filelist SSSgo.efu %xES%

nice.
therube
Posts: 4610
Joined: Thu Sep 03, 2009 6:48 pm

Re: ES, how to ESCape | passed to a BAT file?

Post by therube »

%* == red blue

SET xES=%*
SET x -> xES=red blue
Everything %xES%
Search -> "red"|"blue"

That's fine, just looks odd.
(Yeah, that's odd - looking. Makes one pause, for a bit, heh.)

%* == red house OR blue door
Search -> "red"|"house"|"OR"|"blue"|"door"

so far, so good...


NOW...


%* == "red blue"
SET x -> xES="red blue"
Everything %xES%
-> Press any key to continue . . . The filename, directory name, or volume label syntax is incorrect.

Code: Select all

SSSL.bat:
:: SSSL SjB 12-18-2022   Open an ES File List

:: SSS, but an entire File List rather then a singular file (as with sssgo.TXT)
:: this opens in a "static" version of Everything (rather then in the current...)


@echo off
start /B  cmd /C   "C:\DEV\Locate\15.filelist\Everything.exe"   -instance FILELIST  -read-only -no-db  -filelist C:\OUT\sssGO.efu  %XES%
PAUSE
(The only reason I stuck in %XES% is so that it highlights the search term,
where simply opening the filelist.efu would not do that.)

It also farts on %* == ww:VW
Search -> "ww:VW"
(now granted, all i need to do is to remove [only] the opening " [from the Searchbar...)
NotNull
Posts: 5260
Joined: Wed May 24, 2017 9:22 pm

Re: ES, how to ESCape | passed to a BAT file?

Post by NotNull »

Not sure what the actual quesion is/are (too much rambling for my simple brain :)), but this works here:

SSS.cmd

Code: Select all

start "" "c:\Program Files\Everything 1.5a\Everything64.exe" ^
  -config nul\deleteme.ini ^
  -instance FILELIST ^
  -filelist "C:\path\zzz.efu" ^
  -s* %*
Call it with (example)
SSS ever ^^^| thing

This highlights EVER and THING in the results

The 3 ^^^ are needed as with every next step, escape characters are stripped.
therube
Posts: 4610
Joined: Thu Sep 03, 2009 6:48 pm

Re: ES, how to ESCape | passed to a BAT file?

Post by therube »

With my latest iteration, I added SET XES=%* (mentioned above).

And with that, I'll do somthing like:
Everything.exe -instance filelist -no-db -s* %XES%
.
(Note the difference between -s & -s*.)
therube
Posts: 4610
Joined: Thu Sep 03, 2009 6:48 pm

Re: ES, how to ESCape | passed to a BAT file?

Post by therube »

Does -p break -s* ?


everything -instance filelist -p -s* red ^| blue ^| green

-> "red"|"|"|"blue"|"|"|"green" "C:\out\-s*\"
(C:\out\ is the CWD & -s* is a command line option)

everything -instance filelist -s* red ^| blue ^| green

-> red | blue | green

Without -p, expected results.
With -p, each command line argument is broken out separately & OR'd, & also the directory name where the batch file was run from, & a physical "-s*\" are also included in the search?
therube
Posts: 4610
Joined: Thu Sep 03, 2009 6:48 pm

Re: ES, how to ESCape | passed to a BAT file?

Post by therube »

set parms=%*
set parms=%parms:|=^|%
What is the second SET doing?

Oh, what, it's a substitution?
s/|/^|/g

Oh, sure enough, that's what SET /? says.
I'll have to see how that plays out...
therube
Posts: 4610
Joined: Thu Sep 03, 2009 6:48 pm

Re: ES, how to ESCape | passed to a BAT file?

Post by therube »

how to ESC &

a & b

Code: Select all

set x=a & b    - fail
set x="a & b"  - works, BUT..., then x="a & b" (with literal quotes)
set x=a ^& b   - works, BUT..., then x=a & b   (no quotes)
set x=a ^^^& b - works, BUT..., then x=a ^& b  (no quotes)
BUT...

Everything -s %x% - fails
Everything -s* %x% - fails

Code: Select all

lt:gt:and:quote:slash:slashf:paren:parenc:pipe: - will any of that actually work?
<  >  &   "     \     /      (     )       |    maybe ? directly from a command line, but when used with bath file ?

%PATH:str1=str2%
set XES=%XES:&=^^^&%
NotNull
Posts: 5260
Joined: Wed May 24, 2017 9:22 pm

Re: ES, how to ESCape | passed to a BAT file?

Post by NotNull »

therube wrote: Wed Jan 18, 2023 6:27 pmhow to ESC &
Just like you would escape a "|" ...

set "x=a & b"
-or-
set x=a ^& b
Post Reply