Multi Commander Support Forum
Multi Commander => Support and Feedback => Topic started by: karthik on January 18, 2013, 08:46:33
-
When we do a Ctrl+P, it copies the entire path to clipboard with backward slashes like C:\Users\Karthik\.. etc. Is there a way to copy the path with forward slashes like this C:/Users/Karthik/...
Since I am using this path in unix machines, having forward slashes will help greatly instead of me doing a find replace everytime.
Thanks.
-
MultiScript?
-
Any pointers on how I could start?
-
Any pointers on how I could start?
Multi Commander Documentation (http://multicommander.com/docs) > User Defined Commands and Scripting
-
I tried the following but doesn't seem to work:
@var $arr GetSelectedPaths();
LogDump($arr);
$arr = StrReplace($arr, "\" , "/");
SetClipboardText($arr);
In general, how do I debug a script. Where does the LogDump dump the output?
-
1. There is Multi-Script Debugger under Help menu
2. To see output in the Log window you should use Log function
3. $arr is Array, so in order to use it with StrReplace function you should either convert it to string or go through array in a loop.
UPD. Unfortunately, StrLinesArray2String function doesn't work for me, or maybe i use it incorrectly. So, probably, the only way is to make a loop. Maybe Mathias has the right solution.
-
Try this.
@var $arr = GetSelectedPaths();
@var $str = StrLinesArray2String($arr);
$str = StrReplace($str, "\" , "/");
SetClipboardText($str)
(You can compress it into two lines.)
@var $arr = GetSelectedPaths();
SetClipboardText( StrReplace( StrLinesArray2String( $arr ) , "\" , "/" ) );
-
@var $str = StrLinesArray2String($arr);
That is why it didn't work for me. Declaration in the docs (http://multicommander.com/docs/multiscript/functions/array#strlinesarry2string) differs:
<str> StrLinesArray2String(<array> input, <num> eol);
-
Second parameter is optional so should work both with and without it.
(I will update the doc abort it being optional. )
-
Second parameter is optional so should work both with and without it.
Very strange - now it works. Some time ago i got Error -1.
-
Thanks, Mathias and Jungle.
I can write similar scripts to get finename alone, path alone, etc. And I can assign shortcut hotkeys to these. suppose I assign the default
(Ctrl+P, Ctrl+Shift+P, Alt+Shift+P) shortcuts will it create any problems in terms of MC working and functions?
Is there a way by using multiscript I can get the output of Ctrl+P or Ctrl+Shift+P? In that case, I can use that (instead of GetSelectedPaths()) and replace the backward slashes by forward slashes.
Thanks.
-
See Doc (http://multicommander.com/docs/multiscript/functions/getfilefromview) lots of function for getting different filename part
GetTargetFocusName() / GetTargetFocusName() will give you the current file that are in focus, without path
-
Thanks Mathias.
This works fine but when I select the ".." directory and execute this script I do not get the source path. Where as when I do Ctrl+P when ".." is selected I get the source path. Is there a way to modify the script to get the source path even for ".." directory with this script?
Essentially I am trying to have a replacement for Ctrl+P and make the script do whatever Ctrl+P will do but with forward slashes instead of backward slashes.
Thanks.
-
Thanks Mathias.
This works fine but when I select the ".." directory and execute this script I do not get the source path. Where as when I do Ctrl+P when ".." is selected I get the source path. Is there a way to modify the script to get the source path even for ".." directory with this script?
Essentially I am trying to have a replacement for Ctrl+P and make the script do whatever Ctrl+P will do but with forward slashes instead of backward slashes.
Thanks.
If current item is the ".." item then get current path else get full path with filename, just like Ctrl+P
@var $path = GetSourceFocusName();
if( StrIsEqual($path,"..") )
{
$path = GetSourcePath();
}
else
{
$path = GetSourceFocusPath();
}
-
That helps a lot. Thanks much.