Multi Commander > Support and Feedback

how to refer to a file path without focus?

(1/2) > >>

ariden:
Let's say I have Notepad2 installed in its own folder. I also have another folder named Work with the file named Base.txt inside. I want something that works like this.

If I type into the command line: notepad2
It will open Notepad2.exe, with a blank text file.

If I type into the command line at the Work folder: notepad2 Base.txt
It will open Base.txt with Notepad2.exe.


I've tried making a custom command like this:
MC.Run CMD="C:\Users\Master\Notepad2.exe"
then using an alias for notepad2. It works here for this part.

But when I use Multi Commander while in the Work folder, how do I open the Base.txt with the Notepad2 program as a command? (assume that the default program for text files is Notepad, not Notepad2)

I have tried this:
MC.Run CMD="C:\Users\Master\Notepad2.exe" ARG="${focusfilepath}"

However, this does not work because ${focusfilepath} is only used if there is a focus in Multi Commander. I don't want the command to need a focus, something like a unix shell. I have also tried external commands and other multi-tags, but they don't seem to work. What is the best way to solve this problem?

Thank you.

Mathias (Author):
I have kind of a hard time to understand what problem you trying to solve.

You want to open "base.txt" from a command. And you can not use ${focusfilepath} because the file you want to edit is not in focus ?

May this.


--- Code: ---MC.Run CMD="C:\Users\Master\Notepad2.exe" ARG="${sourcepath}base.txt"
--- End code ---

It will open base.txt located in the folder of the panel that is in focus. But base.txt does not need to be in focus.

ariden:
I know how to focus a file and use ${focusfilepath}, but I don't want to focus to any file while I'm using the command. Also, I just gave base.txt as an example, but I can have other files in there, such as base2.txt, or base3.txt etc.

I'm looking for a custom command that can open any 1 file without a focus, something like this:
notepad2 base.txt (to open base.txt with notepad2), or
notepad2 base2.txt (to open base2.txt with notepad2), or
notepad2 base3.txt (to open base3.txt with notepad2)


It's similar to this: Although I have many folders in C:\Users\, I can just type cd Master but I don't need to focus on the folder called Master for changing directory.

I hope this example is clearer.

Mathias (Author):
Yes, I get that base.txt is just an example.. was try to understand what you want to do. but if you do not want to use  ${focusfilepath}  or ${sourcepath}, how will notepad2 know where to create the file ? If you want the file to be created under the current path then the current path must be included some places.

So you do not what a button /menu option for notepad2, But you want to run "notepad2" from the commandline field inside MC ?
So you want to type (for example) "notepad2.exe myfile.txt" and notepad2 should open with myfile.txt as parameters ? And notepad2 will then create the file "myfile.txt" in current path that is shown ? (or should it be a fixed path ?? since you do not want to use any ${xxx tags ?? )

if it should be under the current shown path then some of the ${xxx tags must be used. else notepad2 will create the file it its working folder that will be the folder that notepad2 is located in, and I do not think you want that..
You can add the STARTIN= parameter to change the working folder for the command that is run.

maybe ?

--- Code: ---MC.Run CMD="C:\Users\Master\Notepad2.exe" ARG=" ${sourcepath}${param:0}"
--- End code ---
or maybe

--- Code: ---MC.Run CMD="C:\Users\Master\Notepad2.exe" STARTIN="${sourcepath}" ARG="${param:0}"
--- End code ---

You can also add the path to notepad2.exe to you PATH environment variable. Then you will not need a command to launch it.

Mathias (Author):
But I do not think you even need to create a custom command at all..

You can also just create an alias.

eg
Alias     Expand to
n          !"C:\Users\Master\notepad2.exe"

then you can write "n myfile.txt" in the commandline field. and "n" is expanded to the full path to notepad2, and programs that are directly launch from the commandline field get the working folder for the current active path.

Navigation

[0] Message Index

[#] Next page

Go to full version