Select ALLSMART (one shortcut for select all files/ all none toggle)

Hello,

I've just moved to Directory Opus (and love it) and I have still few habbits from other filemanager (nexus file), I'm still missing few of them in Dopus.

One is the behavior of the 'select all' which is working like this :

  • the 1st time : it will select all files (=select allfiles)
  • the 2nd time : it will select all files and folders (=select all)
  • the 3rd time : it will unselect all (=select none)

Another way to say it is :
with just the same shortcut (CTRL+A) i'm able to select all files, or select all files
and folder, or unselect all

i find this more effective than using two or three shortcuts.

of course this could be done by scripting / new button, but maybe that could be an idea for a specific feature like a select ALLSMART or select ALLTOGGLE.

an idea among others :wink:

cheers,
Antoine

That's the perfect example for a little script. The TabStats object provides all the info you need. Add a bit of logic and you'll have total control over what to (un)select and when. You'll even get to pick your personal hotkey :slight_smile:

function OnClick(clickData)
{
	var cmd = clickData.func.command;
	cmd.deselect = false;

	var stats = clickData.func.sourcetab.selstats;

	if (stats.dirs == stats.seldirs && stats.files == stats.selfiles) {
		cmd.RunCommand("Select NONE");
	}
	else if (stats.dirs == stats.seldirs || stats.files == stats.selfiles) {
		cmd.RunCommand("Select ALL");
	}
	else if (stats.files != stats.selfiles) {
		cmd.RunCommand("Select ALLFILES");
	}
}

3 Likes

Great thanks :slight_smile:

edit: for special case 'recycle bin' selstats is not possible to use, so it's also possible to add a regular 'select all' behavior as default for recycle bin.

This is explained here : How do I enumerate files in the Recycle Bin?

modified code :

function OnClick(clickData)
{
	var cmd = clickData.func.command;
	cmd.deselect = false;

	var stats = clickData.func.sourcetab.selstats;

	if (clickData.func.sourcetab.path == "::{645FF040-5081-101B-9F08-00AA002F954E}") { // if recycle bin
		cmd.RunCommand("Select ALL");
	}
	else if (stats.dirs == stats.seldirs && stats.files == stats.selfiles) {
		cmd.RunCommand("Select NONE");
	}
	else if (stats.dirs == stats.seldirs || stats.files == stats.selfiles) {
		cmd.RunCommand("Select ALL");
	}
	else if (stats.files != stats.selfiles) {
		cmd.RunCommand("Select ALLFILES");
	}
}

@Leo what would be the code only for select/deselect all files and folders (1.select all, 2.select none)?
Thank you!

function OnClick(clickData)
{
	var cmd = clickData.func.command;
	cmd.deselect = false;

	var stats = clickData.func.sourcetab.selstats;

	// special case for recycle bin
	if (clickData.func.sourcetab.path == "::{645FF040-5081-101B-9F08-00AA002F954E}") { // if recycle bin
		cmd.RunCommand("Select ALL");
	}
	else if (stats.dirs == stats.seldirs && stats.files == stats.selfiles) {
		cmd.RunCommand("Select NONE");
	}
	else {
		cmd.RunCommand("Select ALL");
	}
}
2 Likes

@Leo it works Fantastic, thank you very much!