Multi Commander Support Forum

Multi Commander => Script => Topic started by: karthik on March 27, 2015, 10:44:12

Title: get path name and replace drive and open in target panel
Post by: karthik on March 27, 2015, 10:44:12
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.
Title: Re: get path name and replace drive and open in target panel
Post by: Mathias (Author) on March 27, 2015, 15:07:19
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: [Select]
@var $path = GetSourcePath();
@var $str = StrReplace($path, "Y:" , "P:");
MC.Explorer.Goto PATH={$str}

Title: Re: get path name and replace drive and open in target panel
Post by: karthik on April 01, 2015, 11:08:40
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?
Title: Re: get path name and replace drive and open in target panel
Post by: Mathias (Author) on April 01, 2015, 12:18:24
http://multicommander.com/docs/customcommands_list#mc.explorer.goto

You can use LEFT/RIGHT/SOURCE/TARGET instead of PATH to target specific panels.
Title: Re: get path name and replace drive and open in target panel
Post by: karthik on April 01, 2015, 19:08:29
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?
Title: Re: get path name and replace drive and open in target panel
Post by: Mathias (Author) on April 01, 2015, 19:59:05
http://multicommander.com/docs/customcommands_list#mc.explorer.newbrowser