Multi Commander > Support and Feedback
delete certain files in multiple folders
karthik:
Thanks, Mathias.
This gives me some idea. How can I concatenate two strings in multi-script.
Thanks.
karthik:
I figured that '+' concatenates two strings
I tried to write a script that can give me the path of the 15 folders separated by a ';' and here it is:
@var $arr = GetSelectedPaths();
@var $len = arrayCount($arr)
@var $n
@var $str = $arr[0]
for( $n = 1; $n <= $len-1; $n++)
{
$str = $str + ";" + $arr[$n]
}
SetClipboardText($str)
But I find that the string str does not get updated. Can you let me know what am missing?
Also, can I use this string "str" as the filesearch "look in" box automatically?
Thanks
Mathias (Author):
Not sure.. but I thing it does not like it when you are reading and writing to the same variable..
--- Code: ---$str = $str + ";" + $arr[$n]
--- End code ---
Change that to
--- Code: ---$str += ";" + $arr[$n];
--- End code ---
So that it will then be.
--- Code: ---@var $arr = GetSelectedPaths();
@var $len = arrayCount($arr)
@var $n
@var $str = $arr[0]
@var $new;
for( $n = 1; $n <= $len-1; $n++)
{
$str += ";" + $arr[$n];
}
SetClipboardText($str);
--- End code ---
karthik:
Thanks, Mathias.
The following code works fine now. Am able to get this text to the filesearch window as well.
@var $arr = GetSelectedPaths();
@var $len = arrayCount($arr)
@var $n
@var $str = $arr[0]
@var $new;
for( $n = 1; $n <= $len-1; $n++)
{
$str += ";" + $arr[$n];
}
MC.FileSearch.Search SEARCHIN="{$str}" SEARCHFOR="*.*" EXCLUDE=".backup" AUTOSTART
Now I have '.backup' in exclude. Can I get that as argument.
Ideally, I want to type
del_files '.backup' and it should execute the above script (del_files should be an alias to execute the script), and use the argument '.backup' in the EXCLUDE field of the MC.Filesearch line and give me the result.
Can I do that?
Mathias (Author):
$argcount, $arg[...] are hardcoded variables that exits if script is run with parameters.
--- Code: ---@var $exclude = "";
@var $n;
for( $n = 0; $n < $argcount; $n++ )
{
if( StrLen( $exclude ) > 0)
{
$exclude += " "
}
$exclude += $arg($n);
}
--- End code ---
EXCLUDE list is space separate, so the above part adds a space between them.
Since the command line field also separate by space. you need to quote paths when entering them, if they have space in them.. the space character are kept in $arg[..] so no need to readd quotes..
Navigation
[0] Message Index
[*] Previous page
Go to full version