ikas-mc / ContextMenuForWindows11

Add Custom Context Menu For Windows11
GNU Lesser General Public License v3.0
1.84k stars 90 forks source link

[Proposal] Handle multiple files/folders #6

Closed ayamadori closed 2 years ago

ayamadori commented 2 years ago

It seems to handle only one file now even if multiple files is selected. Is this proposal technically possible? I want to use as the alternative of SendTo folder.

ikas-mc commented 2 years ago

api supports multiple files current difficulty is to find a convenient way to pass parameters

ayamadori commented 2 years ago

If only there is an option that replace {path} to absolute address of all selected files, it's helpful for me.

ikas-mc commented 2 years ago

Maybe app can send the addresses (separated by ;) to script, and then the custom script handles all by itself

ayamadori commented 2 years ago

I think that ` (=halfwidth space) (and") is better than;` for separator because it's more popular. For example, drag & drop to multiple files to Windows Terminal is shown below. image image

ikas-mc commented 2 years ago

I have create a branch for dev and test, but there are still problems... the script needs to split the address, and the " " is difficult to make clear may can only choose "|", script parsing is also necessary

rubenalamina commented 2 years ago

I'm looking forward for it to pass multiple files. I use it for programs like hash verifiers, audio/image taggers (tagscanner, exiftool, etc) and others. So far this is a great utility. If you need someone to check or test let me know, I'm more than willing to lend a hand in testing or verifying your implementation of this.

rxboy1983 commented 2 years ago

Is possible to add option to remove item "Compress to ZIP file"? I cleaned up the context menu and removed a lot of items by editing the shell32.dll.mui and editing the registry. Only item "Compress to ZIP file" I do not know how to remove. I don't need this item because I use WinRAR for archiving.

ikas-mc commented 2 years ago

Is possible to add option to remove item "Compress to ZIP file"? I cleaned up the context menu and removed a lot of items by editing the shell32.dll.mui and editing the registry. Only item "Compress to ZIP file" I do not know how to remove. I don't need this item because I use WinRAR for archiving.

This is difficult, this software uses standard APIs, and there is no way to do it...

rubenalamina commented 2 years ago

This is difficult, this software uses standard APIs, and there is no way to do it...

I think this is out of the scope of your program (at least for now at the least) since it's not meant to customize windows own context menu entries but to create its own entry with whatever commands we want in the submenu.

BTW, any progress on the handling of multiples files/folders?

ikas-mc commented 2 years ago

There are a lot of problems to consider after the test of the branch created before.. Temporarily stopped

kirides commented 2 years ago

In old context menu, selecting multiple files resulted in calling the .bat N-times

  1. Rightclick with many files selected
  2. Select some option configured using regedit
  3. See that the selected option (e.g. Batch script) is opened N times, each invokation with one of the selected paths

i frequently used that behavior to transcode audio and video files using a bunch of ffmpeg based Batch scripts and the aforementioned behavior

ikas-mc commented 2 years ago

future ~ Add an option to call the "exe" for each address

ayamadori commented 2 years ago

Maybe off-topic, this seems to be very difficult... :( https://stackoverflow.com/questions/6714165/powershell-stripping-double-quotes-from-command-line-arguments

ikas-mc commented 2 years ago

1

Added multiple files support.. Depends on the target program to parse.0.. Difficult to use...

https://github.com/ikas-mc/ContextMenuForWindows11/wiki/Help#multiple-files

https://github.com/ikas-mc/ContextMenuForWindows11/tree/dev-multiple

kirides commented 2 years ago

Without checking the implementation, does it "quote" the paths? Without quoting it's more or less "useless". There shouldn't be a need to "escape" the file path, just quoting would suffice (unless you put the input into a shell interpreter like CMD or smth like that, but that's another problem)

almost all applications support input like my.exe "this is a string" and correctly parse the input as a single, char* instead of char[4]{ "this, is, a, string" }

So there would at least need to be an "option" to quote the input before sending it as args

While you can use a batch script to somewhat parse a , delimited input, its very unpleasant to work with third party exe's that follow basic arg parsing

ikas-mc commented 2 years ago

@kirides see wiki "quote" every path as default

I'll upload the code later and release a dev package

ayamadori commented 2 years ago

@ikas-mc I tested on 1.9.0.0_test. In my case, this works well when the delimiter is (space)!

rubenalamina commented 2 years ago

I'll test when I can, the programs I want to pass multiple paths/files to are ExifTool and PNGquant mainly so I'll check if them both threat the parameter correctly. This is good news indeed.

kirides commented 2 years ago

finally came around to test the 1.9.0.0 test build

Works great!

While i did have to modify my scripts slightly for it to work it does a great job. (it passes multiple parameters now instead of invoking for each parameter like in the old fashioned context menu)

here is an example of a batch file that remuxes anything to a mkv

@ECHO OFF

for %%i in (%*) do (
    pushd %%~dpi

    "mkvmerge.exe" -o "remuxed-%%~ni.mkv" ="%%~nxi"
)

and here is the configuration used image

ikas-mc commented 2 years ago

@kirides thanks for test

Based on the previous discussion, using a script is sometimes really necessary

but invoke [exe] for each paths,I will add an option when I have time

ikas-mc commented 2 years ago

Refactored multiple files support implementation

each mode 1

join mode,same as v1.9 2

Need to manually update menu config

see wiki for detail https://github.com/ikas-mc/ContextMenuForWindows11/wiki/Help#multiple-files