Multi Commander > Script

Select Same Name (Selected Files)

(1/2) > >>

pncdaspropagandas:
I wrote a Multi Script to extend the Select Same Name to All Selected Files:

@var $selected_files[] = GetSourceSelectedPaths();
@var $same_name_files[];
@var $same_name_files_iteration[];

@var $n;
@var $i;
@var $aux;

for ($n = 0; $n < arrayCount($selected_files); $n++)
{
    MC.Explorer.SetItemFocus ITEM={PathGetNamePart($selected_files[$n])}
    MC.RunCmd ID="ExplorerPanel.40308"
   
    // SetItemFocus causes the selected files in panel to be unselected
    // only the focused file gets selected
    // so we have to add it to a array and re-select them at the end
    $same_name_files_iteration = GetSourceSelectedFileNames();
    for ($i = 0; $i < arrayCount($same_name_files_iteration); $i++)
    {
        $aux = $same_name_files_iteration[$i];
        arrayAdd($same_name_files, $aux);
    }
}

SetSourceSelected($same_name_files, 0);

Mathias (Author):
It might be because you are mixing custom command and multiscript command in a strange way

MultiScript can call custom command, But it depends on what you do, Also the UI can't be updated until the script is finished since the script is running in the same thread.

Also MultiScript / Custom Command are different
MultiScript is accessing commands in MC at a low level. Behind the UI.  MultiScript does not need UI. ( Unless you call stuff that query UI stuff)
CustomCommand access functions from the UI side. But with the option of customizing the paramters.  But they are accessing it from the UI side, like if the user press the button for the action.

And note sure what you are trying to do.. But there is already commands for selecting all

pncdaspropagandas:
Hmm ok

I did this script because when I select multiple files and run Edit > Select Same Name, I get only the focused file to select files with the same name. So I did this script that applies the internal function in a loop to all selected files.

In the image bellow, I selected both txt files and ran Select Same Name. The result is only 3 files selected intead of 4.

Mathias (Author):
Ok

There are two (possible more) way to do this with script.

#1
Almost as you already have done.. but
Do the matching you self in script.

Get list of all items in view
Get list of selected.
Loop selected list and for every item you loop the AllItemsInView list and if match found input into list.
when everything is done.. set the list with SetSourceSelected
and you can use StrIsWildMatch or StrIsWildMatchNoCase to do the matching.

#2
Get All Selected and loop  them.. and build string that will be a filter matching string. ( eg "Filename* Filename2* filename3*" )
then call custom command
MC.Explorer.Selection.Select  FILTER={$myFilter}

the filter string can look like "MyFile* MySecondFile* YouFile*" and so one..   So just get name and add a * and space after each
(Might need to quote them the filename can have spaces)

pncdaspropagandas:
Did't think about that. That is way better indeed.

Thanks!

Navigation

[0] Message Index

[#] Next page

Go to full version