Author Topic: get path name and replace drive and open in target panel  (Read 20432 times)

karthik

  • Active Member
  • ***
  • Posts: 56
    • View Profile
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)

  • Administrator
  • VIP Member
  • *****
  • Posts: 4416
    • View Profile
    • Multi Commander
Re: get path name and replace drive and open in target panel
« Reply #1 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}


karthik

  • Active Member
  • ***
  • Posts: 56
    • View Profile
Re: get path name and replace drive and open in target panel
« Reply #2 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?
« Last Edit: April 01, 2015, 11:55:34 by karthik »

Mathias (Author)

  • Administrator
  • VIP Member
  • *****
  • Posts: 4416
    • View Profile
    • Multi Commander
Re: get path name and replace drive and open in target panel
« Reply #3 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.

karthik

  • Active Member
  • ***
  • Posts: 56
    • View Profile
Re: get path name and replace drive and open in target panel
« Reply #4 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?