Multi Commander > Script

Search routine

<< < (3/8) > >>

Jungle:
Ulfhednar
Custom commands can be created via Configuration menu.
Then you may open multi-script debugger from the Help menu and choose your command in the dropdown list.

To perform some action on a file/folder you should get its path first by using appropriate functions. They are described in on-line doc.

Mathias (Author):

--- Quote from: Ulfhednar on July 31, 2013, 18:53:19 ---Thanks Mathias
The screen of my tool bar is posted - it shows the 'user commands' menu element is absent on my UI.  Can you not see it?

--- End quote ---
My browser in my phone was acting up..


--- Quote from: Ulfhednar on July 31, 2013, 18:53:19 ---If I understand your advice, my script should be

$s = StrReplace( $s, " " , "." ?\d);

--- End quote ---
If you want to use Regular Expression then use StrRegExpFind, If you want to use a simple Replace substring/character you StrReplace.
You can not use regular expressing in StrReplace.

Ulfhednar:
Thanks Jungle & Mathias, that helps.
I see I will have to pre-define my targets etc now.

It is going to take a while for me to grasp this & how the debugger interfaces, but I am now seeing how it will interact with the selected items & the custom commands list.  I hadn't understood the connection properly before. 

I will persevere & see how it goes.

Ulfhednar:
For purposes of learning to write a script I have a folder called  -
abc v.1.2

I want
abc v1.2

The idea being that I keep a "." following a numeral, stripping any others.  A simple regex transposition I thought....

--- Code: ---((?:[a-zA-Z]+)+)\.
-to-
\1<space>
--- End code ---


I have made a couple of assumptions:-

* I need to get the selected folder name;
* I assign it a variable;
* I then pass that variable to my command string.  Guessing this is something like

--- Code: ---$s = StrRegExpFind( $s, "v." , "v", ".?\d");
--- End code ---

As I don't know PHP & I don't have examples of regex type formulae for MCS (I tried transposing elements of Jungles script but it's too advanced for me at this point) I have been messing for several hours unsuccessfully with various combinations & assignments & getting nowhere.


I began trying a simple rename -  1.2.3.4 to 1234 & failed. :'( :-[

I managed to grab the name-

--- Code: ---@var $arr = GetSourceSelectedFileNames();
--- End code ---
It comes up as an array correctly, then I assumed I would hand the $arr to the rename function (even tho it's technically a string)

--- Code: ---RenameFile( $arr = StrReplace( $arr, "." , "" ) );
--- End code ---

The debugger runs but doesn't red-flag anything (BTW is there a list of error codes somewhere?)
& of course nothing happens.....
 :-[ ???

So I think I need a walkthru or something that helps me define what I need to do in terms of framework & assignments. 
I assume Jungle wasn't born fluent in MCS,  :P so how do I get started with this?  TiA

 

Mathias (Author):
RegExp are a pain. There are many reqex online testers/editor. try one of them they might be helpful when creating regex.

You can not send an entire array into a function that expect a string.. You need to send each item (string) from the array one by one from the array into the function.
Also do not put to much in one line inside each other. the debugger will stop after ever line, so if you got many things in a line then you will not see what went wrong. (You can shorten it afterwards)


--- Code: ---@var $arr = GetSourceSelectedFileNames();
@var $items = arrayCount($arr);
@var $OrgName;
@var $NewName;
@var $n = 0;

for( $n = 0; $n < $items; $n++ )
{
  $CurrentNameFullPath = $arr[ $n ];
  $NewName = PathGetNamePart( $CurrentNameFullPath );
  $NewName = StrReplace( $NewName, "." , "" )
 
  RenameFile( $CurrentNameFullPath, $NewName, "SILENT" );
}

--- End code ---
( Or something like that.. code above is NOT tested.. )

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version