Multi Commander > Script

get path name and replace drive and open in target panel

(1/2) > >>

karthik:
Hello, I want to get the path name in the source panel and replace the drive letter in it and open the result in target panel.
For example, in source panel I have the following path Y:\Projects, I want to open the directory P:\Projects in the target panel. I tried writing a script but doesn't work.

Script:
@var $path = GetSourcePath();
@var $str = StrReplace($path, "Y:" , "P:");
MC.Explorer.Goto PATH=$str

I see that $str has the path P:\Projects but MC.Explorer command does not execute properly. Also, how can I ask MC.Explorer.Goto to open this window in the target panel instead of source panel.

Thanks.

Mathias (Author):
That is because you are mixing two script types..

MC.Explorer.Goto  is a custom command and not a MultiScript command.
Custom command are simple one line commands.

MultiScript Scripts can call CustomCommand but custom command does not know what variables like $str is..  they need to be encapsulated with {} , then they will be evaluated before the command is executed.


--- Code: ---@var $path = GetSourcePath();
@var $str = StrReplace($path, "Y:" , "P:");
MC.Explorer.Goto PATH={$str}

--- End code ---

karthik:
Thanks for the clarity. That helps. Another follow up question: Is there a way I can open it in the target panel instead of the source panel?

Mathias (Author):
http://multicommander.com/docs/customcommands_list#mc.explorer.goto

You can use LEFT/RIGHT/SOURCE/TARGET instead of PATH to target specific panels.

karthik:
I tried the TARGET tag and it worked. Is there a way I can make it appear in a "NEW" target tab instead of replacing a older one?

Navigation

[0] Message Index

[#] Next page

Go to full version