[SOLVED] How to press ENTER on a video and it runs a batch file?

Discussion related to "Everything" 1.5 Alpha.
Post Reply
Gabarito
Posts: 77
Joined: Thu Apr 25, 2013 4:20 pm

[SOLVED] How to press ENTER on a video and it runs a batch file?

Post by Gabarito »

Hi.

I'm trying to make a list of all videos I play. To do that, I have a batch file that get the filename and add it to a TXT file. After that, it call the system default player to run that video.

Using an explorer tool, like Directory Opus, I can assign that batch file to File Types double-click action and it does the task.
But how to do the same using Everything?

I can assign a shortcut to this batch file, but I'd like to do that simply using ENTER key. So, how to override the default behavior of it to call the batch file and not the default player?

In other words, how to press ENTER on a video file, inside Everything grid, and it invoke the batch file and not the system default player instead?

It could be done via plugin feature?

I'm using Everything 1.5.0.1372a.

Below, the batch file:

Code: Select all

@echo off
mode con cp select=1252

dir %1 /b >> "D:\Programas\GomPlayer - Histórico.txt"

if "%~x1" == ".mkv" goto :MKV
if "%~x1" == ".mp4" goto :MP4
if "%~x1" == ".png" goto :PNG
if "%~x1" == ".docx" goto :DOCX


goto :FIM

:MKV
start "C:\Program Files (x86)\GRETECH\GOMPlayer\GOM.exe" %1
goto :FIM

:MP4
start "C:\Program Files (x86)\GRETECH\GOMPlayer\GOM.exe" %1
goto :FIM

:PNG
start "C:\Program Files (x86)\ACD Systems\ACDSee\ACDSee.exe" %1
goto :FIM

:DOCX
start "C:\Program Files (x86)\Microsoft Office\Office14\WINWORD.EXE" %1
goto :FIM

:FIM
Thanks.
Last edited by Gabarito on Sun May 05, 2024 11:08 pm, edited 1 time in total.
NotNull
Posts: 5458
Joined: Wed May 24, 2017 9:22 pm

Re: How to press ENTER and it runs a batch file?

Post by NotNull »

In Everything 1.5 it iis possible to define internal file associations too.
More info here

That thread describes 2 (more or less) different ways to get this done.
In your case, you don't need a context-menu entry and "just" want ENTER/double-click on a MKV/MP4 file to run your batchfile.
  • Go to Menu => Tools => Options => Advanced
  • In the Show settings containing: field, type custom
  • Select custom_open_commands from the list
  • Set its value to:

    Code: Select all

    [{"type":2,"filter":"*.mkv;*.mp4","command":"$exec(\"C:\\path to\\LogAndPlay.cmd\" \"%1\")"}
    
    Replace C:\\path to\\LogAndPlay.cmd with the actual path to your script; use "\\" instead of "\"
  • OK
  • Done!
No try double-clicking (/ENTER) a MKV file in the Everything resultlist.


LogAndPlay.cmd

Code: Select all

@echo off
rem mode con cp select=1252
chcp 1252

>> "D:\Programas\GomPlayer - Histórico.txt" echo "%~f1"

goto %~x1
goto :FIM


:.MKV
:.MP4
   start "" "C:\Program Files (x86)\GRETECH\GOMPlayer\GOM.exe" "%~f1"

:FIM
Gabarito
Posts: 77
Joined: Thu Apr 25, 2013 4:20 pm

Re: How to press ENTER and it runs a batch file?

Post by Gabarito »

NotNull wrote: Sun May 05, 2024 6:50 pm In Everything 1.5 it iis possible to define internal file associations too.
Wonderful!
Working very well!
Image


Many thanks.
Gabarito
Posts: 77
Joined: Thu Apr 25, 2013 4:20 pm

Re: How to press ENTER on a video and it runs a batch file?

Post by Gabarito »

And I also appreciate the improvement for my batch script.
;)
Gabarito
Posts: 77
Joined: Thu Apr 25, 2013 4:20 pm

Re: How to press ENTER on a video and it runs a batch file?

Post by Gabarito »

One more thing:
How to send just the filename and not the full path to the LOG file?

Using DIR command, is with "/b" parameter.

Code: Select all

dir %1 /b >> "D:\Programas\GomPlayer - Histórico.txt"
But your suggestion is sending the full path.
NotNull
Posts: 5458
Joined: Wed May 24, 2017 9:22 pm

Re: How to press ENTER on a video and it runs a batch file?

Post by NotNull »

Gabarito wrote: Sun May 05, 2024 7:35 pm How to send just the filename and not the full path to the LOG file?
Without "", just like dir /b ?

Code: Select all

>> "D:\Programas\GomPlayer - Histórico.txt" echo %~nx1
Gabarito
Posts: 77
Joined: Thu Apr 25, 2013 4:20 pm

Re: How to press ENTER on a video and it runs a batch file?

Post by Gabarito »

NotNull wrote: Sun May 05, 2024 7:48 pm Without "", just like dir /b ?
Image


But...
More problems...

My batch file is this:

Code: Select all

@echo off
chcp 1252

>> "D:\Programas\GomPlayer - Histórico.txt" echo %~nx1

goto %~x1

:.AVI
:.FLV
:.MKV
:.MP4
:.MPG
:.RMVB
:.WEBM
   start "" "C:\Program Files (x86)\GRETECH\GOMPlayer\GOM.exe" "%~f1"
goto :FIM

:.DOCX
   start "" "C:\Program Files (x86)\Microsoft Office\Office14\WINWORD.EXE" "%~f1"
goto :FIM

:.HTML
   start "" "C:\Program Files (x86)\Mozilla Firefox\private_browsing.exe" "%~f1"
goto :FIM

:FIM
But only video files are playing as expected.
DOCX and HTML open with system's associated players, but they don't use the batch EXE files and don't sending filename to LOG.

I tried to put "(" and ")" for each group of file types, without success.
NotNull
Posts: 5458
Joined: Wed May 24, 2017 9:22 pm

Re: How to press ENTER on a video and it runs a batch file?

Post by NotNull »

Completely missed the other file extensions ...

Anyway ...
More problems...
More solutions :D

Add the other extensions to:

Code: Select all

[{"type":2,"filter":"*.mkv;*.mp4","command":"$exec(\"C:\\path to\\LogAndPlay.cmd\" \"%1\")"}
like:

Code: Select all

[{"type":2,"filter":"*.AVI;*.FLV;*.MKV;*.MP4;*.MPG;*.RMVB;*.WEBM;*.DOCX;*.HTML","command":"$exec(\"C:\\path to\\LogAndPlay.cmd\" \"%1\")"}
Gabarito
Posts: 77
Joined: Thu Apr 25, 2013 4:20 pm

Re: How to press ENTER on a video and it runs a batch file?

Post by Gabarito »

NotNull wrote: Sun May 05, 2024 8:25 pm More solutions :D
Perfect!
Image


Many thanks.

Thread fully solved.
Gabarito
Posts: 77
Joined: Thu Apr 25, 2013 4:20 pm

Re: [SOLVED] How to press ENTER on a video and it runs a batch file?

Post by Gabarito »

One more question.

I'm trying to assign another custom command, now to open image files using other image browser than the system default one.
I used custom_open_command01 in addition to custom_open_command, that already existed.

custom_open_command01

Code: Select all

[{"type":2,"filter":"*.JPG;*.JPEG;*.BMP;*.GIF;*.PNG",*.PSD;*.JPE;*.WEBP"command":"$exec(\"C:\\Program Files $(x86$)\\GoSoft\\image_browsing.exe\" \"%1\")"}

custom_open_command

Code: Select all

[{"type":2,"filter":"*.AVI;*.DOCX;*.HTML;*.FLV;*.MKV;*.MP4;*.MPG;*.RMVB;*.WEBM","command":"$exec(\"D:\\Programas\\GomPlayer LOG - Histórico versão 03.bat\" \"%1\")"}
But it doesn't work.

I put "$" to escape "(" and ")".

Whats is wrong?
void
Developer
Posts: 16665
Joined: Fri Oct 16, 2009 11:31 pm

Re: [SOLVED] How to press ENTER on a video and it runs a batch file?

Post by void »

Please try the following:

Reset your custom_open_command01 to an empty value.
Set your custom_open_command to:

Code: Select all

[{"type":2,"filter":"*.AVI;*.DOCX;*.HTML;*.FLV;*.MKV;*.MP4;*.MPG;*.RMVB;*.WEBM","command":"$exec(\"D:\\Programas\\GomPlayer LOG - Histórico versão 03.bat\" \"%1\")"},{"type":2,"filter":"*.JPG;*.JPEG;*.BMP;*.GIF;*.PNG,*.PSD;*.JPE;*.WEBP","command":"$exec(\"C:\\Program Files $(x86$)\\GoSoft\\image_browsing.exe\" \"%1\")"}]
Please make sure you add the trailing ]

Custom Open Commands
Gabarito
Posts: 77
Joined: Thu Apr 25, 2013 4:20 pm

Re: [SOLVED] How to press ENTER on a video and it runs a batch file?

Post by Gabarito »

Perfect!
Image


Many thanks.
Post Reply