Multi Commander Support Forum
Multi Commander => Support and Feedback => Topic started by: karthik on March 17, 2014, 17:18:26
-
Hello,
I have a main directory, which has say 20 folders. Each folder has a certain set of files (*.txt,*.dat,*.xls, etc). Out of these 20 folders, I want to keep only *.txt in 15 of these folders (which I select) and delete the rest of the files in the 15 folders. The remaining folders, I don't want to be touched.
Currently, I just select the 15 folders, move it to a temp directory (and while moving give options so that the move command moves only *.txt) and the delete the source folders and then move the folders from the temp directory to my working directory.
Is there a easier way to do this in MC?
Thanks.
-
Delete using filter is disabled since it is not fixed yet.. But you can use search..
Start Search panel
search for everything in the location you want to delete
Then right click on a .txt file an select "exclude .txt" and they are removed from search result.
sort by ext. (so that files and folders are not mixed.)
then select all files. (do not select the folders)
press delete to delete all the selected files. (what should be all files except the .txt file that you excluded)
-
Thanks, Mathias.
The way you have mentioned, "search for everything in the location you want to delete" - the problem is the location has 20 folders and I want to search only in 15 folders. The search panel doesn't allow me to do search in multiple folders.
Thanks.
-
Is there a way to do a scripting. If yes, just give some pointers and I will attempt to do it.
-
The way you have mentioned, "search for everything in the location you want to delete" - the problem is the location has 20 folders and I want to search only in 15 folders. The search panel doesn't allow me to do search in multiple folders.
You can enter multiple paths and separate then with ";" eg "C:\MyFolder1;C:\MyFolder2;C:\MyFolder3"
Or you can exclude folders in the "Exclude filter box"
Is there a way to do a scripting. If yes, just give some pointers and I will attempt to do it.
There is some scripting.. But not sure if it helps
http://multicommander.com/docs/customcommands_list#mc.filesearch.search
or more advanced, scan the filesystem and find the file you want to delete your self
http://multicommander.com/docs/multiscript/functions/filesystem
-
Thanks, Mathias.
This gives me some idea. How can I concatenate two strings in multi-script.
Thanks.
-
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
-
Not sure.. but I thing it does not like it when you are reading and writing to the same variable..
$str = $str + ";" + $arr[$n]
Change that to
$str += ";" + $arr[$n];
So that it will then be.
@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);
-
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?
-
$argcount, $arg[...] are hardcoded variables that exits if script is run with parameters.
@var $exclude = "";
@var $n;
for( $n = 0; $n < $argcount; $n++ )
{
if( StrLen( $exclude ) > 0)
{
$exclude += " "
}
$exclude += $arg($n);
}
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..