Multi Commander > Script
Debugger in 4.3 hangs MC on error
Mathias (Author):
MC.Explorer.Goto
For going to a path
Send 1 as second paramter to PathGetNamePart and it will strip file extension
http://multicommander.com/docs/multiscript/functions/filesystem#pathgetnamepart
Ulfhednar:
Thanks again, I had managed to forget the link between MC.Explorer commands & scripts in looking through all the script functions :-[
You pre-empted my query on tokenize...!! :D
----- I had been looking at this -
--- Code: ---<array> StrTokenize2Array(<str> input, <str> delimiter);
--- End code ---
but it doesn't like this
--- Code: ---$arr StrTokenize2Array($arr input, "." delimiter);
@var $name = $arr[0];
@var $ext = $arr[1];
--- End code ---
Not sure what is wrong with my syntax ::) It splits the string into letters & gives $arr[xx] for each character but this is not useful for a filename that is not a constant pattern.
But now I can skip past that issue for this script. :P
Mathias (Author):
--- Quote from: Ulfhednar on June 01, 2014, 19:56:05 ---Thanks again, I had managed to forget the link between MC.Explorer commands & scripts in looking through all the script functions :-[
You pre-empted my query on tokenize...!! :D
----- I had been looking at this -
--- Code: ---<array> StrTokenize2Array(<str> input, <str> delimiter);
--- End code ---
but it doesn't like this
--- Code: ---$arr StrTokenize2Array($arr input, "." delimiter);
@var $name = $arr[0];
@var $ext = $arr[1];
--- End code ---
Not sure what is wrong with my syntax ::) It splits the string into letters & gives $arr[xx] for each character but this is not useful for a filename that is not a constant pattern.
But now I can skip past that issue for this script. :P
--- End quote ---
--- Code: ---@var $path = "C:\\MyFolder\\MyFiles.txt";
@var $arr = StrTokenize2Array($path, ".");
--- End code ---
But the problem with that is that if any other part of the path happens to have a "." it will be bad.
You can also use string function
--- Code: ---@var $path = "C:\\MyFolder\\MyFiles.txt";
@var $positionOfLastDot = StrRFind($path, ".");
@var $name = StrSub($path , 0, $positionOfLastDot);
@var $ext = StrSub($path , $positionOfLastDot, -1);
--- End code ---
There are many ways to do the same thing :)
Ulfhednar:
This works well
--- Code: ---@var $now = GetTime();
@var $date = FormatDate( "dd-MM-yyyy" , $now );
@var $time = FormatTime( "HHmm", $now);
@var $folder;
@var $FolderBaseName = GetTargetPath();
@var $path = GetSourceFocusName();
@var $name = PathGetNamePart( $path , 1 );
$folder = $FolderBaseName ^ $name + " " + $date + " " +$time +"Hrs";
MC.Filesystem.Makedir PATH="{$folder}"
MC.Explorer.Goto TARGET ="{$folder}"
--- End code ---
My only problem is not getting the new folder to open in the inactive pane.
Thanks for helping me get this far, I appreciate the fact that you have many more important things to do! ;)
Ulfhednar:
We are Cross-posting I think!
I like the lastdot option for extensions, this will be useful if a version # is included in the source.
I guess the trick is finding the optimal solution given the possible uses. It is great to have options tho, MS-DOS type environments are a nightmare ;D
Thanks for giving me so many details on all this it will help me out a lot in the future. :) 8)
Navigation
[0] Message Index
[#] Next page
[*] Previous page
Go to full version