Custom Open Commands

Discussion related to "Everything" 1.5 Alpha.
Post Reply
void
Developer
Posts: 16630
Joined: Fri Oct 16, 2009 11:31 pm

Custom Open Commands

Post by void »

Everything 1.5 adds Custom Open Commands.

Custom Open Commands allows you to execute files or folders with a custom program or script.



To set a Custom Open Command:
  • In Everything 1.5, from the Tools menu, click Options.
  • Click the Advanced tab on the left.
  • To the right of Show settings containing, search for:
    custom
  • Select custom_open_command01.
  • Set the value to a custom command
  • For example:
    $exec("C:\Program Files $(x86$)\ExternalFileManager\ExternalFileManager.exe" "%1")
  • Click OK.


To assign a keyboard shortcut to a Custom Open Command:
  • In Everything 1.5, from the Tools menu, click Options.
  • Click the keyboard tab on the left.
  • To the right of Show commands containing, search for:
    custom
  • Select File | Custom Open 1.
  • Click Add....
  • Press a new keyboard shortcut and click OK.
  • Click OK.


To create a custom command and also show a context menu item:
  • In Everything 1.5, from the Tools menu, click Options.
  • Click the Advanced tab on the left.
  • To the right of Show settings containing, search for:
    command
  • Select custom_open_commands.
  • Change the value to a JSON array of command objects.
  • For example:

    Code: Select all

    [{"name":"TC","type":2,"filter"="*.7z;*.zip;*.rar;*.aes;*.jpg;*.zpaq;*.EOC","command"="$exec(\"C:\\Tools\\Wincmd\\Totalcmd64.exe\" /a /o /s \"%1\")"},{"name":"AkelPad","type":2,"filter"="*.ini","command"="$exec(\"C:\\Tools\\AkelPad\\AkelPad.exe\" \"%1\")"}]
    
  • Click OK.
Leave name empty to use the command by default. (Context menu -> Open)
Otherwise, the command is shown under the context menu with the specified name.
horst.epp
Posts: 1442
Joined: Fri Apr 04, 2014 3:24 pm

Re: Custom Open Commands

Post by horst.epp »

void wrote: Thu Aug 03, 2023 6:47 am Everything 1.5 adds Custom Open Commands.
Custom Open Commands allows you to execute files or folders with a custom program or script.

To set a Custom Open Command:
  • In Everything 1.5, from the Tools menu, click Options.
  • Click the Advanced tab on the left.
  • To the right of Show settings containing, search for:
    custom
  • Select custom_open_command01.
  • Set the value to a custom command
  • For example:
    $exec("C:\Program Files $(x86$)\ExternalFileManager\ExternalFileManager.exe" "%1")
  • Click OK.
I hoped that Custom Open Commands would allow making them depending on the type of results
like the Everything Toolbar does it.

My rules for example
Screenshot - 03.08.2023 , 17_35_01.png
Screenshot - 03.08.2023 , 17_35_01.png (24.12 KiB) Viewed 36821 times
therube
Posts: 4947
Joined: Thu Sep 03, 2009 6:48 pm

Re: Custom Open Commands

Post by therube »

Does

$exec("COMMAND" "%1")

only accept a single argument, %1?

Or is there a way to pass multiple arguments such they get executed by a single COMMAND (instance)?
Like:

$exec("COMMAND" "%1" "%2" "%3")
or
$exec("COMMAND" "%*")

Or is there an alternative to $exec to do such?

Likewise can COMMAND itself accept arguments?
$exec("e:\windows\system32\cmd.exe /c" "go.bat" "%*")


(So far, I've not found a way to do such.)
NotNull
Posts: 5449
Joined: Wed May 24, 2017 9:22 pm

Re: Custom Open Commands

Post by NotNull »

Did not have time to look at this (but definitely will as this is very useful!), but you probably can make this work using an external utiity called singleinstance.exe. Described here
void
Developer
Posts: 16630
Joined: Fri Oct 16, 2009 11:31 pm

Re: Custom Open Commands

Post by void »

I have put %* support on my TODO list.

Thank you for the suggestion.

For now, Everything will call your command separately for each file.
Only %1 is expanded with the current filename.


I hoped that Custom Open Commands would allow making them depending on the type of results
I have put on my TODO list to support custom commands by filter.

Thank you for the suggestion.
void
Developer
Posts: 16630
Joined: Fri Oct 16, 2009 11:31 pm

Re: Custom Open Commands

Post by void »

Everything 1.5.0.1355a improves custom commands.

%* will now execute the command once, with %* being replaced with all the selected filenames.

For example, if the current selection is:
C:\Windows\Notepad.exe
C:\Windows\Explorer.exe

and the command is:

$exec("c:\programs\foo.bat" %*)

The following is executed once:

"c:\programs\foo.bat" "C:\Windows\Notepad.exe" "C:\Windows\Explorer.exe"



Everything 1.5.0.1355a adds open_file_commands and open_folder_commands.

These settings can be used to execute commands based on filenames filters.

To override the default open command for a specific filename filter:
  • In Everything 1.5, from the Tools menu, click Options.
  • Click the Advanced tab on the left.
  • To the right of Show settings containing, search for:
    open command
  • Select open_file_commands.
  • Set the value to a JSON object of filename filters and open commands.
    For example:
    [{"filter":"*.7z;*.zip;*.rar;*.aes;*.jpg;*.zpaq;*.EOC","command":"$exec(\"C:\\Tools\\Wincmd\\Totalcmd64.exe\" /a /o /s \"%1\")"},{"filter":"*.ini","command":"$exec(\"C:\\Tools\\AkelPad\\AkelPad.exe\" \"%1\")"}]
  • Click OK.
Custom context menus are still on my TODO list.
horst.epp
Posts: 1442
Joined: Fri Apr 04, 2014 3:24 pm

Re: Custom Open Commands

Post by horst.epp »

Thanks a lot for the open_file_commands enhancement :D
Even including my Toolbar rules as example :)

Btw. open_folder_commands is not important for me
but will be fine for others.
On my system, all folder calls are shown using Total Commander by registry settings.
therube
Posts: 4947
Joined: Thu Sep 03, 2009 6:48 pm

Re: Custom Open Commands

Post by therube »

Much improved.
Thank you :-).
therube
Posts: 4947
Joined: Thu Sep 03, 2009 6:48 pm

Re: Custom Open Commands

Post by therube »

To point out, Custom Open Commands is not "LFN-aware" (i.e., attempting to open a LFN will fail [Win7]).

viewtopic.php?p=60128#p60128
void
Developer
Posts: 16630
Joined: Fri Oct 16, 2009 11:31 pm

Re: Custom Open Commands

Post by void »

I will trial using the shortname in the next alpha update when the full path exceeds 259 characters.
meteorquake
Posts: 492
Joined: Thu Dec 15, 2016 9:44 pm

Re: Custom Open Commands

Post by meteorquake »

I'm a bit late to the party here... wonderful news.
I'll probably do a mixture of unfiltered and filtered.
* Filtered will be useful for concepts such as "View" and "Edit" which open a program appropriate to file extension. So for image types "View" may be a lightweight program (XNView, IrfanView) and "Edit" a heavy weight (Gimp).
* Others would be unextension-filtered, targeting some exact program (e.g. winmerge) or move commands (.vbs) to enable sorting items into a couple of boxes by keyboard (can also be done by de-maximising the window and having a folder of shortcuts).
These I think will work quite nicely with shortcuts.
* My older idea I'll pop here again since the context is relevant for it (so apologies for the repeat!), is that you can have custom columns assigned to these custom_commands. E.g. when you search for e.g. ext:jpg and can have a custom column saying "View" which is linked to a custom command that Views the file, another column could say "Edit", another column could be a move to some folder, and you can click the commands beside the files to action them. This is a mouse alternative to keyboard, useful when you're in "mouse mode".
* Another idea would be able to have a dockable pane where you can fix favourites - shortcuts to commands and folders included, but could be bookmarks, filters or anything - so you could have shortcuts to commands like View or Edit custom commands and some folder shortcuts for your task, giving them names on the pane, and you drag the files onto them to perform an action on the file (open/view/move).
void
Developer
Posts: 16630
Joined: Fri Oct 16, 2009 11:31 pm

Re: Custom Open Commands

Post by void »

I have on my TODO list to add a Name field to the existing custom command JSON list.
If the name is set, a new context menu item is shown.

Like what Everything Toolbar is doing.

You'll be able to add a custom view / preview context menu item with this.
I will consider options to override commands for existing verbs.
Thank you for the suggestion.
horst.epp
Posts: 1442
Joined: Fri Apr 04, 2014 3:24 pm

Re: Custom Open Commands

Post by horst.epp »

void wrote: Thu Aug 31, 2023 4:19 am I will trial using the shortname in the next alpha update when the full path exceeds 259 characters.
There are many users which have completely disabled short names.
Everything should not try to overcome problems of tools which are not long name aware.
That's the problem of these tools, and they will only be changed or replaced if enough users complain.
void
Developer
Posts: 16630
Joined: Fri Oct 16, 2009 11:31 pm

Re: Custom Open Commands

Post by void »

Thank you for the suggestions horst.epp,

The Windows shell is still limited to 259 characters. (ShellExecute)

Everything is already using shortnames (for very long filenames) when executed directly. (for example: $exec("%1") )
However, Everything doesn't use shortnames when %1 is used as a parameter (for example: $exec("c:\my program.exe" "%1") )

Most programs will handle really long filenames as a parameter.

I will add a shell_execute_short_parameters ini setting that will use shortnames for very long filenames when passed as a parameter.
This setting will be disabled by default.



Some notes on how Everything uses short names:
If a filename is very long, Everything will first try with a short path to preserve the long name part.
If the short-path + long name part is still too long, Everything will try a short-path and short-name.

You can manage these settings with shell_short_path and shell_short_basename.
Both are enabled by default.
therube
Posts: 4947
Joined: Thu Sep 03, 2009 6:48 pm

Re: Custom Open Commands

Post by therube »

I'm going to assume that "full command", or at least "fullfilename" ($*), has a size limit of 4096 characters (including parenthesis & spaces).

What is the debug output when you open a single filename?
Is the parameter generated by Everything expected?
viewtopic.php?p=60272#p60272
Can't say, yet, but I can say if you exceed 4096 chars, only a single file name is passed (to IrfanView).
horst.epp
Posts: 1442
Joined: Fri Apr 04, 2014 3:24 pm

Re: Custom Open Commands

Post by horst.epp »

therube wrote: Mon Sep 04, 2023 2:42 pm I'm going to assume that "full command", or at least "fullfilename" ($*), has a size limit of 4096 characters (including parenthesis & spaces).

What is the debug output when you open a single filename?
Is the parameter generated by Everything expected?
viewtopic.php?p=60272#p60272
Can't say, yet, but I can say if you exceed 4096 chars, only a single file name is passed (to IrfanView).
It doesn't make sense to feed any program with a large list of files with such path lenghts.
IrfanView has a command line parameter /filelist=filenames.txt for this.
I use it in Total commander, which provides a file containing the paths from any number of selected files.
therube
Posts: 4947
Joined: Thu Sep 03, 2009 6:48 pm

Re: Custom Open Commands

Post by therube »

It doesn't make sense to feed any program with a large list of files with such path lengths.
Why? (In any case...)
IrfanView has a command line parameter /filelist=filenames.txt
True.
Likewise if you use the irfanview_shell_extension, that too will work
therube
Posts: 4947
Joined: Thu Sep 03, 2009 6:48 pm

Re: Custom Open Commands

Post by therube »

if you exceed 4096 chars, only a single file name is passed (to IrfanView)
>4096, 1 picture opens, regularly (i.e., not in /thumbs mode)
with 1, being the "first" file name, based on current sort,
i.e., the first filename in "fullfilename" is what opens

Code: Select all

FOCUS 0
FOCUS restore
COMMAND 41513
exec: first expr
exec: command $exec("C:\BIN\i_view32.exe" %* /thumbs)
exec: fullfilename "... .jpg"
exec: depth 0
exec: exec "C:\BIN\i_view32.exe" %* /thumbs)
exec: depth 1
exec: got "C:\BIN\i_view32.exe" "T: ... .jpg" /thumbs
exec: shellexecute file:C:\BIN\i_view32.exe param:"T:\ ... .jpg" /thumbs
Parameters '"T: ... .jpg" /thumbs
Directory 'C:\BIN'
File 'C:\BIN\i_view32.exe'
Mask 00000100
Enter ShellExecute
ShellExecute OK
sub buf killed
set 148 run history in 0.001595 seconds
exec: main thread regained focus
WM_ACTIVATE 00000000 00000000, lastfocus 01c716b8, current focus 01c716b8
WM_ACTIVATE MINIMIZED 0
update m 0 0cc5ee48
WM_ACTIVATE 00000001 00000000, lastfocus 01c716b8, current focus 00000000
WM_ACTIVATE MINIMIZED 0
FOCUS 0
FOCUS restore
update index E:
USN DATA_OVERWRITE i_view32.ini

Even better, with ~128K bytes, you get an outright fail ;-).
ShellExecuteExW(): GetLastError(): 206: failed to execute C:\BIN\i_view32.exe

Code: Select all

Everything: 1.5.0.1355a (x86)
OS: Windows NT 6.1 7601 (x64)
Config: custom_open_command02=$exec("C:\BIN\i_view32.exe" %* /thumbs)
FOCUS restore
COMMAND 41513
exec: first expr
exec: command $exec("C:\BIN\i_view32.exe" %* /thumbs)

exec: depth 0
exec: exec "C:\BIN\i_view32.exe" %* /thumbs)
exec: depth 1



Directory 'C:\BIN'
File 'C:\BIN\i_view32.exe'
Mask 00000100
Enter ShellExecute
WM_ACTIVATE 00000000 010818ce, lastfocus 01c716b8, current focus 01c716b8
WM_ACTIVATE MINIMIZED 0
WM_ACTIVATE 00000001 010818ce, lastfocus 01c716b8, current focus 010818ce
WM_ACTIVATE MINIMIZED 0
FOCUS 0
FOCUS restore
ShellExecuteExW(): GetLastError(): 206: failed to execute C:\BIN\i_view32.exe
sub buf killed
set 3563 run history in 0.067466 seconds
exec: main thread regained focus
WM_ACTIVATE 00000000 00000000, lastfocus 01c716b8, current focus 01c716b8
WM_ACTIVATE MINIMIZED 0
horst.epp
Posts: 1442
Joined: Fri Apr 04, 2014 3:24 pm

Re: Custom Open Commands

Post by horst.epp »

therube wrote: Tue Sep 05, 2023 2:41 pm
It doesn't make sense to feed any program with a large list of files with such path lengths.
Why? (In any case...)
IrfanView has a command line parameter /filelist=filenames.txt
True.
Likewise if you use the irfanview_shell_extension, that too will work
The Shell extension is limited by the number of entries Windows allows.
The filelist has no such limits.
therube
Posts: 4947
Joined: Thu Sep 03, 2009 6:48 pm

Re: Custom Open Commands

Post by therube »

To note:
fullfilename
Does contain the expected results.

The filelist has no such limits.
But your file editor (used to create the filelist) might, heh ;-).
horst.epp
Posts: 1442
Joined: Fri Apr 04, 2014 3:24 pm

Re: Custom Open Commands

Post by horst.epp »

therube wrote: Tue Sep 05, 2023 4:03 pm To note:
fullfilename
Does contain the expected results.

The filelist has no such limits.
But your file editor (used to create the filelist) might, heh ;-).
No editor needed.
Just select the files in Total Commander and it generates a temp file with the paths.
This temp file is given as parameter to IrfanView /filelist
void
Developer
Posts: 16630
Joined: Fri Oct 16, 2009 11:31 pm

Re: Custom Open Commands

Post by void »

Everything 1.5.0.1356a adds an advanced setting to pass very long filenames on the command line as short path names.

This feature is off by default.

To pass very long filenames on the command line as short path names:
  • In Everything 1.5, from the Tools menu, click Options.
  • Click the Advanced tab on the left.
  • To the right of Show settings containing, search for:
    short
  • Select shell_execute_short_parameters.
  • Set the value to: true
  • Click OK.
shell_execute_short_parameters



Also renamed shell_short_basename to shell_short_name
therube
Posts: 4947
Joined: Thu Sep 03, 2009 6:48 pm

Re: Custom Open Commands

Post by therube »

(Without testing, yet, I'll say) wunderbar :-).


---

Just select the files in Total Commander and it generates a temp file with the paths
I'm not familiar with that, but from the sound of it, sounds similar to how the T.I. DX10 OS's
Show File (SF) command worked.

(But it's been so long now, that I don't really remember just how SF worked.
That said, I do use programs like, ShowTX, where I ceremoniously rename its' ShowTx.exe to SF.exe ;-).)
horst.epp
Posts: 1442
Joined: Fri Apr 04, 2014 3:24 pm

Re: Custom Open Commands

Post by horst.epp »

therube wrote: Thu Sep 07, 2023 6:50 pm
Just select the files in Total Commander and it generates a temp file with the paths
I'm not familiar with that, but from the sound of it, sounds similar to how the T.I. DX10 OS's
Show File (SF) command worked.

(But it's been so long now, that I don't really remember just how SF worked.
That said, I do use programs like, ShowTX, where I ceremoniously rename its' ShowTx.exe to SF.exe ;-).)
The purpose of this TC function is not to display files.
It gives the name of the temporary file as parameter %UL, %UF, %WL, %WF depending on the wanted encoding
to any program configured in a TC button bar.
therube
Posts: 4947
Joined: Thu Sep 03, 2009 6:48 pm

Re: Custom Open Commands

Post by therube »

Right.
If I recall correctly, DX10 "wrote" to a "temporary file" - somewhere. And you could access that data by various means, including SF, to "show it", or to edit it, or pass that data elsewhere... You didn't need to know where or what it was, only that it existed, & various other programs likewise knew that & could use its' data as they wished.
therube
Posts: 4947
Joined: Thu Sep 03, 2009 6:48 pm

Re: Custom Open Commands

Post by therube »

It doesn't make sense to feed any program with a large list of files
To me it does - for efficiency reasons.


Alt+U (unique)
+
Ctrl+A (select all)
+
Alt+I (irfanview /thumbs)

(or simply hitting Alt+I, if wanted files are already selected)

is FAR more efficient then

Alt+U
Ctrl+A
right-click context menu -> Irfanview oprerations -> /search for/ 'Start thumbnails for selected files' -> click

Now, Alt+U + Ctrl+A + Alt+I, does work, if your dataset is small enough
If the same worked regardless of data length would be a great improvement

(& of course this isn't limited to Irfanview, but any program where you would like to pass
[enough] data from one, Everything, to another)

(now, if it can't be done, so be it
& yes there may be alternatives, autohotkey perhaps ?, but if it were "just there", & worked...)


(as it is now, i use both methods, depending on the size of the inputs)
void
Developer
Posts: 16630
Joined: Fri Oct 16, 2009 11:31 pm

Re: Custom Open Commands

Post by void »

Everything 1.5.0.1357a improves custom open commands.

Please note the new ini setting: custom_open_commands

open_file_commands and open_folder_commands have been removed.

Example usage:

Code: Select all

custom_open_commands=[{"name":"TC","type":2,"filter"="*.7z;*.zip;*.rar;*.aes;*.jpg;*.zpaq;*.EOC","command"="$exec(\"C:\\Tools\\Wincmd\\Totalcmd64.exe\" /a /o /s \"%1\")"},{"name":"AkelPad","type":2,"filter"="*.ini","command"="$exec(\"C:\\Tools\\AkelPad\\AkelPad.exe\" \"%1\")"}]


The custom command is shown in the context menu with the specified "name".
If "name" is not specified, the custom command is not shown in the context menu.

For example, the following will show TC in the context menu when right clicking a 7z or zip file:

Code: Select all

custom_open_commands=[{"name":"TC","type":2,"filter"="*.7z;*.zip","command"="$exec(\"C:\\Tools\\Wincmd\\Totalcmd64.exe\" /a /o /s \"%1\")"}"}]


"type" can be one of the following values:
  • 1 = Folders only.
  • 2 = Files only.
  • 3 = Folders and files.
If "type" is not specified, the default: Files only is used.
tuska
Posts: 1052
Joined: Thu Jul 13, 2017 9:14 am

Re: Custom Open Commands

Post by tuska »

Hi,

I am having trouble converting the theme to the new .ini settings.
These codes do not work for me.

Everything.ini

Code: Select all

custom_open_commands=
custom_open_command01=[{"name":"Notepad++","type":2,"filter"="*.txt;*.ini","command"="$exec(\"C:\\totalcmd\\Tools\\Notepad++\\notepad++.exe\" \"%1\")"}]
custom_open_command02=[{"name":"MPC","type":2,"filter"="*.mp4;*.mov","command"="$exec(\"C:\\Program Files $(x86$)\\K-Lite Codec Pack\\MPC-HC64\\mpc-hc64.exe\" \"%1\")"}]
custom_open_command03=[{"name":"MPC","type":2,"filter"="*.mp4;*.mov","command"="$exec(\"C:\\Program Files $(x86$)\\K-Lite Codec Pack\\MPC-HC64\\mpc-hc64.exe\" \"%1\")"}"}]
custom_open_command04=
custom_open_command05=
custom_open_command06=
custom_open_command07=
custom_open_command08=
custom_open_command09=
custom_open_command10=
custom_open_command11=
custom_open_command12=
options_last_advanced_setting=custom_open_commands
Instead of notepad++.exe, EmEditor Pro (standard editor) is opened for .ini and .txt files.
Instead of mpc-hc64.exe, Windows Media Player is opened for .mov files and VLC Plus Player for .mp4 files.

Does anyone have an idea why?
void
Developer
Posts: 16630
Joined: Fri Oct 16, 2009 11:31 pm

Re: Custom Open Commands

Post by void »

Leave custom_open_command01..custom_open_command12 undefined and set only custom_open_commands.

Please try:

Code: Select all

custom_open_commands=[{"name":"Notepad++","type":2,"filter"="*.txt;*.ini","command"="$exec(\"C:\\totalcmd\\Tools\\Notepad++\\notepad++.exe\" \"%1\")"},{"name":"MPC","type":2,"filter"="*.mp4;*.mov","command"="$exec(\"C:\\Program Files $(x86$)\\K-Lite Codec Pack\\MPC-HC64\\mpc-hc64.exe\" \"%1\")"},{"name":"MPC","type":2,"filter"="*.mp4;*.mov","command"="$exec(\"C:\\Program Files $(x86$)\\K-Lite Codec Pack\\MPC-HC64\\mpc-hc64.exe\" \"%1\")"}"}]
custom_open_command01=
custom_open_command02=
custom_open_command03=
tuska
Posts: 1052
Joined: Thu Jul 13, 2017 9:14 am

Re: Custom Open Commands

Post by tuska »

void wrote: Fri Oct 06, 2023 1:03 am Leave custom_open_command01..custom_open_command12 undefined and set only custom_open_commands.
Thanks for the prompt help!
That worked.
----------------------------------
Example
Everything Options - 1.5.0.1357a (x64) > Advanced > Show settings containing: custom

Code: Select all

custom_open_commands
Value for custom_open_commands: ... Please see also the next post! ...

Code: Select all

[{"name":"IrfanView","type":2,"filter"="*.jpg;*.jpeg;*.psd","command"="$exec(\"C:\\totalcmd\\Tools\\IrfanView-portable-64bit\\IrfanView\\i_view64.exe\" \"%1\")"}"},{"name":"Notepad++","type":2,"filter"="*.txt;*.ini","command"="$exec(\"C:\\totalcmd\\Tools\\Notepad++\\notepad++.exe\" \"%1\")"},{"name":"MPC","type":2,"filter"="*.mp4;*.mov","command"="$exec(\"C:\\Program Files $(x86$)\\K-Lite Codec Pack\\MPC-HC64\\mpc-hc64.exe\" \"%1\")"},{"name":"TC","type":2,"filter"="*.7z;*.zip","command"="$exec(\"C:\\totalcmd\\Totalcmd64.exe\" /O /A /S \"%1)"}"}]
Note:
[{"name":"IrfanView" ... "}"}, --> context menu: IrfanView
 {"name":"TC" ........... "}"}] --> context menu: TC (= Total Commander)
tuska
Posts: 1052
Joined: Thu Jul 13, 2017 9:14 am

Re: Custom Open Commands

Post by tuska »

Hi,
Is there a character limit in the "custom_open_commands" field?

This code works (164 characters):

Code: Select all

[{"name":"IrfanView","type":2,"filter"="*.jpg;*.jpeg;*.psd","command"="$exec(\"C:\\totalcmd\\Tools\\IrfanView-portable-64bit\\IrfanView\\i_view64.exe\" \"%1\")"}"}]
This code also works (394 characters):

Code: Select all

[{"name":"Notepad++","type":2,"filter"="*.txt;*.ini","command"="$exec(\"C:\\totalcmd\\Tools\\Notepad++\\notepad++.exe\" \"%1\")"},{"name":"MPC-HC64","type":2,"filter"="*.mp4;*.mov","command"="$exec(\"C:\\Program Files $(x86$)\\K-Lite Codec Pack\\MPC-HC64\\mpc-hc64.exe\" \"%1\")"},{"name":"TC","type":2,"filter"="*.7z;*.zip","command"="$exec(\"C:\\totalcmd\\Totalcmd64.exe\" /O /A /S \"%1)"}"}]
If I put both code parts together, the code (557 characters) no longer works (e.g. Notepad++, MPC-HC64, Total Commander)
but the context menu does:

Code: Select all

[{"name":"IrfanView","type":2,"filter"="*.jpg;*.jpeg;*.psd","command"="$exec(\"C:\\totalcmd\\Tools\\IrfanView-portable-64bit\\IrfanView\\i_view64.exe\" \"%1\")"}"},{"name":"Notepad++","type":2,"filter"="*.txt;*.ini","command"="$exec(\"C:\\totalcmd\\Tools\\Notepad++\\notepad++.exe\" \"%1\")"},{"name":"MPC-HC64","type":2,"filter"="*.mp4;*.mov","command"="$exec(\"C:\\Program Files $(x86$)\\K-Lite Codec Pack\\MPC-HC64\\mpc-hc64.exe\" \"%1\")"},{"name":"TC","type":2,"filter"="*.7z;*.zip","command"="$exec(\"C:\\totalcmd\\Totalcmd64.exe\" /O /A /S \"%1)"}"}]
void
Developer
Posts: 16630
Joined: Fri Oct 16, 2009 11:31 pm

Re: Custom Open Commands

Post by void »

Please try the following:

Code: Select all

[{"name":"IrfanView","type":2,"filter":"*.jpg;*.jpeg;*.psd","command":"$exec(\"C:\\totalcmd\\Tools\\IrfanView-portable-64bit\\IrfanView\\i_view64.exe\" \"%1\")"},{"name":"Notepad++","type":2,"filter":"*.txt;*.ini","command":"$exec(\"C:\\totalcmd\\Tools\\Notepad++\\notepad++.exe\" \"%1\")"},{"name":"MPC","type":2,"filter":"*.mp4;*.mov","command":"$exec(\"C:\\Program Files $(x86$)\\K-Lite Codec Pack\\MPC-HC64\\mpc-hc64.exe\" \"%1\")"},{"name":"TC","type":2,"filter":"*.7z;*.zip","command":"$exec(\"C:\\totalcmd\\Totalcmd64.exe\" /O /A /S \"%1\")"}]
https://codebeautify.org/json-syntax-highlighting



I am going to add a table editor at some stage...
tuska
Posts: 1052
Joined: Thu Jul 13, 2017 9:14 am

Re: Custom Open Commands

Post by tuska »

Thank you!
This works! :)

Now that was tricky:
With IrfanView you left out the setting for the context menu (and the code above works):

Code: Select all

... i_view64.exe\" \"%1\")"}
I had the following setting (including the context menu):

Code: Select all

... i_view64.exe\" \"%1\")"}"}
void
Developer
Posts: 16630
Joined: Fri Oct 16, 2009 11:31 pm

Re: Custom Open Commands

Post by void »

tuska
Posts: 1052
Joined: Thu Jul 13, 2017 9:14 am

Re: Custom Open Commands

Post by tuska »

void wrote: Fri Oct 06, 2023 4:43 am Another online viewer with a table view:

https://jsoneditoronline.org/#left=cloud.d4f853cf0b9743938f69a03913ea93f9
This looks very clearly arranged.

This link is really great:
Ctrl+V, Format

Thank you for the links!
NotNull
Posts: 5449
Joined: Wed May 24, 2017 9:22 pm

Re: Custom Open Commands

Post by NotNull »

Another viewer: Notepad++ with the JSON Viewer plugin installed:


2023-10-13 18_08_30-_new 1 - Notepad++.png
2023-10-13 18_08_30-_new 1 - Notepad++.png (37.88 KiB) Viewed 34008 times
tuska
Posts: 1052
Joined: Thu Jul 13, 2017 9:14 am

Re: Custom Open Commands

Post by tuska »

NotNull wrote: Fri Oct 13, 2023 4:09 pm Another viewer: Notepad++ with the JSON Viewer plugin installed:
Thank you! :)

This info is also very helpful!
biship
Posts: 5
Joined: Wed Oct 04, 2023 3:35 pm

Re: Custom Open Commands

Post by biship »

In Win 11, I have notepad++ associated with text documents.
When I use content: and find the text in the file, opening the file from Everything will load the file into notepad++, but at the default line 1 position.
notepad++ has a -n command line argument to go directly to the line when opening.
There also is a -p for position, but I don't know what that does.
Is there a way to set up Everything 1.5a to go to the line where the text was found, directly from the search interface?
Does Everything even index the line number (or position) of contents of files?
Thanks for any help!
NotNull
Posts: 5449
Joined: Wed May 24, 2017 9:22 pm

Re: Custom Open Commands

Post by NotNull »

Currently not possible. Would be a neat feature though.
void
Developer
Posts: 16630
Joined: Fri Oct 16, 2009 11:31 pm

Re: Custom Open Commands

Post by void »

Everything 1.5.0.1360a makes a change to custom_open_commands.

Custom commands with no name are now the default commands.

Custom commands with a name are no longer executed by default.
Custom commands with a name can only be executed through the context menu.



If you were using custom_open_commands as the default commands:
  • In Everything 1.5, from the Tools menu, click Options.
  • Click the Advanced tab on the left.
  • To the right of Show settings containing, search for:
    custom
  • Select custom_open_commands.
  • Change any "name":"..." values to: "name":""
  • Click OK.
(This wasn't the most elegant solution, but I needed a way to NOT open a custom command as the default)



I have put on my TODO list to add a property that describes the first line of a content match.
Thank you for the suggestion.
mvdeckard
Posts: 29
Joined: Tue Oct 25, 2022 11:46 pm

Re: Custom Open Commands

Post by mvdeckard »

Thanks for this godsend of a feature (custom open commands).

Reading through the thread here, another vote for Everything being able to optionally package selected files into an intermediary list.txt and passing that to the external program. I understand TC has this ability but I try to do everything with Everything.

Even with sending shortened path\filenames, there's still a bottleneck trying to pass an elephant through a keyhole, where many programs will choke beyond a certain number. Use case example, sending a few thousand jpg, mp3 or mp4 files to an external program to shuffle-play them (IrfanView or MPV). These programs error beyond a certain number of paths\files passed from command line, but happily accept a list.txt of almost unlimited length - I've tested 50,000+.
Last edited by mvdeckard on Thu Feb 15, 2024 4:37 am, edited 1 time in total.
mvdeckard
Posts: 29
Joined: Tue Oct 25, 2022 11:46 pm

Re: Custom Open Commands

Post by mvdeckard »

To create a hotkey-assignable custom command that runs a batch file against the parent folder of a selected file in the Everything results window, could someone advise how to format that? I've been messing with it for an hour and not getting anywhere, and the information in this thread is a bit confusing (are people no longer using custom_open_command01 through custom_open_command12 and instead just throwing all the commands as a single JSON line into custom_open_commands=? I don't see a way to bind a hotkey to custom_open_commands. Perhaps there could be a $hotkey= parameter for each command if the single JSON line is the new standard going forward.

My batch file "C:\batch\thumb.cmd" accepts a path as its %1 input. i.e. C:\batch\thumb.cmd V:\videos\foldername
Last edited by mvdeckard on Thu Feb 15, 2024 4:52 am, edited 2 times in total.
void
Developer
Posts: 16630
Joined: Fri Oct 16, 2009 11:31 pm

Re: Custom Open Commands

Post by void »

I have put on my TODO list to add an $export(...) function that you can call before $exec(...)

I'll report back once I have something going.



For now, your best bet is to manually export as txt from Everything -> File -> Export -> Save as type -> TXT



I'll look into mapping custom_verbxx => custom_open_commands->name so you can bind a key.
void
Developer
Posts: 16630
Joined: Fri Oct 16, 2009 11:31 pm

Re: Custom Open Commands

Post by void »

I still have $export() on my TODO list.

Everything currently calls $exec() for each result.
I will have to add a new parameter, maybe: %>
Which will only call $exec() once and is replaced with the exported filename.

I still have concerns about the encoding to use in the file list as there's no real standard.
I'm guessing most applications will want ANSI text.


I'll look into mapping custom_verbxx => custom_open_commands->name so you can bind a key.
This was too quirky.

I will consider support for keyboard shortcuts in custom_open_commands.

For now, please consider adding a custom_open_command01 and binding a key to custom_open_command01:
  • In Everything 1.5, from the Tools menu, click Options.
  • Click the Advanced tab on the left.
  • To the right of Show settings containing, search for:
    custom
  • Select: custom_open_command01
  • Set the value to your custom command.
    (copy this command from your existing custom_open_commands)
    ---
  • Click the Keyboard tab on the left.
  • To the right of Show commands containing, search for:
    custom
  • Select: custom_open_command01
  • Click Add....
  • Press a new keyboard shortcut and click OK.
  • Click OK.
Unfortunately, this means you need to duplicate the command in both custom_open_commands and custom_open_commands01 if you want to show the context menu item and bind a keyboard shortcut.
mvdeckard
Posts: 29
Joined: Tue Oct 25, 2022 11:46 pm

Re: Custom Open Commands

Post by mvdeckard »

I'm curious on custom_open_command syntax/parameters to open sidecar files; to swap the extension of the filename sent to the default program.

Example, I have C:\file.mp4, C:\file.jpg, C:\file.json. With C:\file.mp4 selected in results window, I'd like to:

Shift+Enter = open file.jpg with default viewer (i_view32.exe)
CTRL+Enter = open file.json with default app.
Last edited by mvdeckard on Mon Sep 09, 2024 12:29 am, edited 2 times in total.
void
Developer
Posts: 16630
Joined: Fri Oct 16, 2009 11:31 pm

Re: Custom Open Commands

Post by void »

Please try the following custom command:

[{"name":"Open jpg sidecar","type":"2","filter":"*.mp4","command":"$exec(\"<remove-extension:%1>.jpg\")"}]


Right click the mp4 file -> Open jpg sidecar
mvdeckard
Posts: 29
Joined: Tue Oct 25, 2022 11:46 pm

Re: Custom Open Commands

Post by mvdeckard »

^ Appreciated! That syntax worked for custom_open_commands once I blanked the value of the Name key (""), but did not work for custom_open_command01, etc until I removed the backslashes:

[{"name":"Open JPG sidecar","type":"2","filter":"*.mp4","command":"$exec("<remove-extension:%1>.jpg")"}]
_______________________________________________________________^_______________________^
meteorquake
Posts: 492
Joined: Thu Dec 15, 2016 9:44 pm

Re: Custom Open Commands

Post by meteorquake »

What I tend to do is resize the window so there is a slight edge gap, where I put a second window (usually Everything) where I have programs appear (typically using a search but could be a folder of shortcuts), and I drag files from Everything onto those programs when I want to action the files in a certain way. I usually do so separately but on a quick check it seems to action them as a group rather than one by one.
However it would be great to be able to pin files, folders, bookmarks etc to a dedicated Favourites pane in the Folder Bar section that can be clicked or dropped onto in a similar way.
Post Reply