Everything in Windows ContextMenu

If you are experiencing problems with "Everything", post here for assistance.
Post Reply
tytn
Posts: 13
Joined: Wed Dec 14, 2016 7:13 pm

Everything in Windows ContextMenu

Post by tytn »

Which commandline option i must take for right click (context menu) on file, to search the file name in Everything over all drives?
When i take "Everything.exe -name-part "%1"", search Everything only the exactly right filenames. I want search not only excatly "testfile.txt", but also want find "testfile.txt.txt" and "test2-testfile.txt.bak", etc., over all drives.

thx
void
Developer
Posts: 16684
Joined: Fri Oct 16, 2009 11:31 pm

Re: Everything in Windows ContextMenu

Post by void »

Please try changing your Everything command line to:
Everything.exe -search "%1"

/support/everything/command_line_options/#-search
tytn
Posts: 13
Joined: Wed Dec 14, 2016 7:13 pm

Re: Everything in Windows ContextMenu

Post by tytn »

Everything.exe -search "%1" returns the complete path for search. I need/want only the Filename.
When i try "Everything.exe" -search nopath: "%1" -filter "Everything"" gives Error: "... could not open File ..."
My Everything Version is 1.4.1.921 (x64).
void
Developer
Posts: 16684
Joined: Fri Oct 16, 2009 11:31 pm

Re: Everything in Windows ContextMenu

Post by void »

Please try:
Everything.exe -search nopath:"%1"
tytn
Posts: 13
Joined: Wed Dec 14, 2016 7:13 pm

Re: Everything in Windows ContextMenu

Post by tytn »

grrr, blank sign between nopath: and percent ...

Everything.exe -search nopath:"%1" also give the complete path for search return.
vanisk
Posts: 152
Joined: Sat Oct 27, 2018 11:33 am

Re: Everything in Windows ContextMenu

Post by vanisk »

I never tried this. But out of curiosity tried creating shell extension to achieve what tytn is asking for.

tried "Everything.exe -name-part "%1*" which opens everything with search text
nopath:wfn:"testfile.txt*"
which in turn search for "testfile.txt" and "testfile.txt.txt" but not "test2-testfile.txt.bak"

Also i seek for alternate to %1 [like %~n1 DOS] to only send filename without extension to everything and to use -s, but can't find a straightforward method. My guess is to create a intermediate script to parse the given filename with path [from context menu] and to send only filename w/o extension to Everything.exe -s.
tytn
Posts: 13
Joined: Wed Dec 14, 2016 7:13 pm

Re: Everything in Windows ContextMenu

Post by tytn »

This is what I'm looking for.
I need a Everything Command Line Options to dissolve to "nopath:nowfn:" or "nopath:noww:"
NotNull
Posts: 5458
Joined: Wed May 24, 2017 9:22 pm

Re: Everything in Windows ContextMenu

Post by NotNull »

vanisk wrote: Fri Nov 09, 2018 10:39 am Also i seek for alternate to %1 [like %~n1 DOS] to only send filename without extension to everything
I read this thread 3 times and still didn't understand the question. Your %~n1 finally made everything clear.
For other people reading this:
If you use the context menu for a file, it will pass "C:\path\my file.txt" to the associated program.
@tytn wants it to pass "my file.txt" (or "my file"; not sure)


In the past I did quite a few experimnts with context menu variables. Conclusion: there is no such thing as %~n1. Unfortunately ...

Your alternative - passing the "%1" to a CMD script to get just the filename out of it - is a good solution.
But there is an alternative: adding multiple commands to the registry.

Instructions
  • Decide which version you like
  • Save the corresponding code as WhereElse.reg somewhere on your system
  • Optional: change the path towhere your Everything.exe is
  • Double-click WhereElse.reg
  • Done
Now you have a "Where else?" in the context menu of your files.


Version 1
If the selected file is "c:\path\My File.txt" and you want to search for "My File"

Code: Select all

Windows Registry Editor Version 5.00

[HKEY_CURRENT_USER\Software\Classes\*\Shell\Where else?\command]
@="cmd.exe /c for %%a in (\"%1\") do start \"\" \"c:\\Program Files\\everything\\everything.exe\" -search \"\"\"\"%%~na\"\"\"\""

Version 2
If the selected file is "c:\path\My File.txt" and you want to search for "My File.txt"

Code: Select all

Windows Registry Editor Version 5.00

[HKEY_CURRENT_USER\Software\Classes\*\Shell\Where else?\command]
@="cmd.exe /c for %%a in (\"%1\") do start \"\" \"c:\\Program Files\\everything\\everything.exe\" -search \"\"\"\"%%~nxa\"\"\"\""


Note:
- CMD doesn't support passing multiple files to it, so single file only.
void
Developer
Posts: 16684
Joined: Fri Oct 16, 2009 11:31 pm

Re: Everything in Windows ContextMenu

Post by void »

To make things a little easier, I've added -stem <filename>, -base-name <filename> and -extension <filename> command line options for the next version of Everything

For example:
Everything.exe -stem "c:\foo\bar.txt"
will search for: "bar"

Everything.exe -base-name "c:\foo\bar.txt"
will search for: "bar.txt"

Everything.exe -extension "c:\foo\bar.txt"
will search for: ext:txt

I've also added stem:<filename>, basename:<filename> and extension:<filename> "query string functions" for the next version of Everything

For example, searching for:
stem:<c:\foo\bar.txt>
will search for:
bar

For example, searching for:
basename:<c:\foo\bar.txt>
will search for:
bar.txt

For example, searching for:
extension:<c:\foo\bar.txt>
will search for:
txt

For example, searching for:
strlen:<c:\foo\bar.txt>
will search for:
14

With these "query string functions" you could do something like:
Everything.exe -search "stem:<%1>"
tytn
Posts: 13
Joined: Wed Dec 14, 2016 7:13 pm

Re: Everything in Windows ContextMenu

Post by tytn »

@void You're a treasure :-* :D
therube
Posts: 4955
Joined: Thu Sep 03, 2009 6:48 pm

Re: Everything in Windows ContextMenu

Post by therube »

Should -base-name be named, -basename?
I only say, given that basename is a "normal" UNIX command ;-).

Should -stem be named, -name-part?
I only say, given that a namepartdupe: function already exists.

---

PS: Without those ES options, with a bit more work, suppose you could take the list of files found by ES, finagle them with a batch file to get the basename (%~n1) of the wanted file names.

I use a "basename" here, https://forums.informaction.com/viewtop ... 996#p73996.

Code: Select all

In addition, substitution of FOR variable references has been enhanced.
You can now use the following optional syntax:

    %~I         - expands %I removing any surrounding quotes (")
    %~fI        - expands %I to a fully qualified path name
    %~dI        - expands %I to a drive letter only
    %~pI        - expands %I to a path only
    %~nI        - expands %I to a file name only
    %~xI        - expands %I to a file extension only
    %~sI        - expanded path contains short names only
    %~aI        - expands %I to file attributes of file
    %~tI        - expands %I to date/time of file
    %~zI        - expands %I to size of file
    %~$PATH:I   - searches the directories listed in the PATH
                   environment variable and expands %I to the
                   fully qualified name of the first one found.
                   If the environment variable name is not
                   defined or the file is not found by the
                   search, then this modifier expands to the
                   empty string

FOR /?

Code: Select all

Runs a specified command for each file in a set of files.

FOR %variable IN (set) DO command [command-parameters]

  %variable  Specifies a single letter replaceable parameter.
  (set)      Specifies a set of one or more files.  Wildcards may be used.
  command    Specifies the command to carry out for each file.
  command-parameters
             Specifies parameters or switches for the specified command.

To use the FOR command in a batch program, specify %%variable instead
of %variable.  Variable names are case sensitive, so %i is different
from %I.

If Command Extensions are enabled, the following additional
forms of the FOR command are supported:

FOR /D %variable IN (set) DO command [command-parameters]

    If set contains wildcards, then specifies to match against directory
    names instead of file names.

FOR /R [[drive:]path] %variable IN (set) DO command [command-parameters]

    Walks the directory tree rooted at [drive:]path, executing the FOR
    statement in each directory of the tree.  If no directory
    specification is specified after /R then the current directory is
    assumed.  If set is just a single period (.) character then it
    will just enumerate the directory tree.

FOR /L %variable IN (start,step,end) DO command [command-parameters]

    The set is a sequence of numbers from start to end, by step amount.
    So (1,1,5) would generate the sequence 1 2 3 4 5 and (5,-1,1) would
    generate the sequence (5 4 3 2 1)

FOR /F ["options"] %variable IN (file-set) DO command [command-parameters]
FOR /F ["options"] %variable IN ("string") DO command [command-parameters]
FOR /F ["options"] %variable IN ('command') DO command [command-parameters]

    or, if usebackq option present:

FOR /F ["options"] %variable IN (file-set) DO command [command-parameters]
FOR /F ["options"] %variable IN ('string') DO command [command-parameters]
FOR /F ["options"] %variable IN (`command`) DO command [command-parameters]

    filenameset is one or more file names.  Each file is opened, read
    and processed before going on to the next file in filenameset.
    Processing consists of reading in the file, breaking it up into
    individual lines of text and then parsing each line into zero or
    more tokens.  The body of the for loop is then called with the
    variable value(s) set to the found token string(s).  By default, /F
    passes the first blank separated token from each line of each file.
    Blank lines are skipped.  You can override the default parsing
    behavior by specifying the optional "options" parameter.  This
    is a quoted string which contains one or more keywords to specify
    different parsing options.  The keywords are:

        eol=c           - specifies an end of line comment character
                          (just one)
        skip=n          - specifies the number of lines to skip at the
                          beginning of the file.
        delims=xxx      - specifies a delimiter set.  This replaces the
                          default delimiter set of space and tab.
        tokens=x,y,m-n  - specifies which tokens from each line are to
                          be passed to the for body for each iteration.
                          This will cause additional variable names to
                          be allocated.  The m-n form is a range,
                          specifying the mth through the nth tokens.  If
                          the last character in the tokens= string is an
                          asterisk, then an additional variable is
                          allocated and receives the remaining text on
                          the line after the last token parsed.
        usebackq        - specifies that the new semantics are in force,
                          where a back quoted string is executed as a
                          command and a single quoted string is a
                          literal string command and allows the use of
                          double quotes to quote file names in
                          filenameset.

    Some examples might help:

FOR /F "eol=; tokens=2,3* delims=, " %i in (myfile.txt) do @echo %i %j %k

    would parse each line in myfile.txt, ignoring lines that begin with
    a semicolon, passing the 2nd and 3rd token from each line to the for
    body, with tokens delimited by commas and/or spaces.  Notice the for
    body statements reference %i to get the 2nd token, %j to get the
    3rd token, and %k to get all remaining tokens after the 3rd.  For
    file names that contain spaces, you need to quote the filenames with
    double quotes.  In order to use double quotes in this manner, you also
    need to use the usebackq option, otherwise the double quotes will be
    interpreted as defining a literal string to parse.

    %i is explicitly declared in the for statement and the %j and %k
    are implicitly declared via the tokens= option.  You can specify up
    to 26 tokens via the tokens= line, provided it does not cause an
    attempt to declare a variable higher than the letter 'z' or 'Z'.
    Remember, FOR variables are single-letter, case sensitive, global, 
    and you can't have more than 52 total active at any one time.

    You can also use the FOR /F parsing logic on an immediate string, by
    making the filenameset between the parenthesis a quoted string,
    using single quote characters.  It will be treated as a single line
    of input from a file and parsed.

    Finally, you can use the FOR /F command to parse the output of a
    command.  You do this by making the filenameset between the
    parenthesis a back quoted string.  It will be treated as a command
    line, which is passed to a child CMD.EXE and the output is captured
    into memory and parsed as if it was a file.  So the following
    example:

      FOR /F "usebackq delims==" %i IN (`set`) DO @echo %i

    would enumerate the environment variable names in the current
    environment.

In addition, substitution of FOR variable references has been enhanced.
You can now use the following optional syntax:

    %~I         - expands %I removing any surrounding quotes (")
    %~fI        - expands %I to a fully qualified path name
    %~dI        - expands %I to a drive letter only
    %~pI        - expands %I to a path only
    %~nI        - expands %I to a file name only
    %~xI        - expands %I to a file extension only
    %~sI        - expanded path contains short names only
    %~aI        - expands %I to file attributes of file
    %~tI        - expands %I to date/time of file
    %~zI        - expands %I to size of file
    %~$PATH:I   - searches the directories listed in the PATH
                   environment variable and expands %I to the
                   fully qualified name of the first one found.
                   If the environment variable name is not
                   defined or the file is not found by the
                   search, then this modifier expands to the
                   empty string

The modifiers can be combined to get compound results:

    %~dpI       - expands %I to a drive letter and path only
    %~nxI       - expands %I to a file name and extension only
    %~fsI       - expands %I to a full path name with short names only
    %~dp$PATH:I - searches the directories listed in the PATH
                   environment variable for %I and expands to the
                   drive letter and path of the first one found.
    %~ftzaI     - expands %I to a DIR like output line

In the above examples %I and PATH can be replaced by other valid
values.  The %~ syntax is terminated by a valid FOR variable name.
Picking upper case variable names like %I makes it more readable and
avoids confusion with the modifiers, which are not case sensitive.

basename:

Code: Select all

Usage: basename NAME [SUFFIX]

Print NAME with any leading directory components removed.
If specified, also remove a trailing SUFFIX.
void
Developer
Posts: 16684
Joined: Fri Oct 16, 2009 11:31 pm

Re: Everything in Windows ContextMenu

Post by void »

In Everything, the - in function names / command line options is optional.
-basename and -namepart will work.

I am still working on the syntax, it is most likely going to change a little before release, what I currently have is:
<basename:"C:\foo\bar.txt">

The < and > and quotes are optional, for example, the above search would be the same as:
basename:C:\foo\bar.txt

However, the < and > escapes can be used to combine text and make the query clear, for example:
<basename:"C:\folder with a space\bar.txt">.tmp
would search for:
bar.txt.tmp

Calls with multiple arguments works too, for example:
string.repeat:foo,2
would search for:
foofoo

-or-

<string.repeat:"a b",2>123
would search for:
a ba b123

I'm also experimenting with a light version of javascript, for example:
eval:"hello world !".subString(1,4)
which would search for:
ell

-or-

size:eval:1<<17
which would search for:
size:131072
Functions in Everything that take a number, will automatically use eval, so size:1<<17 would be the same.

These functions mostly exist for setting up a powerful search from the command line with %1
Post Reply