Author Topic: how do I run an external program on all selected files?  (Read 13857 times)

pmennen

  • Junior Member
  • **
  • Posts: 24
    • View Profile
how do I run an external program on all selected files?
« on: August 22, 2015, 20:51:31 »
I usually delete without using the recycle bin, so I've told MC to default to not using the recycle bin. I usually use the delete button in the file commands toolbar and I'm happy with the way that works. However, I occasionally want to delete to the recycle bin and I decided to add a button to the command line bar for that purpose. Using a google search, I found an external program called "binit.exe" which will delete a file to the recycle bin (without a prompt which is what I consider appropriate for a delete which is easily reversed). So I added the user command C:\util\binit.exe "${sourcefocuspath}" and named it "Delete to recycle bin". Then I created a new button in the command line bar using this command and chose an appropriate looking icon. I'm pleased to say that when I select a file and click this new button it behaves exactly has I predicted and hoped!. Unfortunately if I select more than one file, when I click on the button, only the last selected file gets deleted. (I suspect this is no surprise to those of you who understand user commands which I obviously don't.) Anyway, can anyone give me a suggestion for how to modify the button so that it deletes all the selected files?

Thanks.
~Paul

Mathias (Author)

  • Administrator
  • VIP Member
  • *****
  • Posts: 4416
    • View Profile
    • Multi Commander
Re: how do I run an external program on all selected files?
« Reply #1 on: August 24, 2015, 08:23:07 »
It might work if you in the option box check "Run separately for all provided files and folders"
and then use ${currentfilepath} instead. Then it should loop all selected files.
http://multicommander.com/docs/UDC_custom   (Scroll down to options)


Else you need to use the 'Multi Script' command type,
That however require that you are somewhat familiar with writing scripts or such.

From MultiScript you can get a list of the selected files,
Then you can either send them to binit.exe or you can call the Delete/DeleteFiles MultiScript functions
http://multicommander.com/docs/multiscript/functions/getfilefromview
http://multicommander.com/docs/multiscript/functions/filesystem





pmennen

  • Junior Member
  • **
  • Posts: 24
    • View Profile
Re: how do I run an external program on all selected files?
« Reply #2 on: August 24, 2015, 11:07:35 »
It might work if you in the option box check "Run separately for all provided files and folders"
and then use ${currentfilepath} instead. Then it should loop all selected files.
http://multicommander.com/docs/UDC_custom   (Scroll down to options)

Wow, this works.
It would have helped a whole lot if you had mentioned that I should use the MC.Run command.
I suspect this was so obvious to you that you didn't even think it deserved mention, but I saw many dozens of things that I thought might work but they didn't. Then finally I saw the Run command under the MC group and realized that this was the thing I needed. Anyway, the correct custom user command that I needed looks like this:

#options (RunSeparate)
MC.Run CMD="C:\util\binit.exe" ARG="${currentfilepath}"

I'm not sure why you were suspicious that this may not work ... but the button actually does exactly what I want!
Many thanks for your help.

~Paul