This script selects all items (files and folders) between the first and the last item of the current selection.
If the selection looks like this
it will look like this after the script has run:
function OnClick(clickData) {
var cmd = clickData.func.command;
var tab = clickData.func.sourcetab;
cmd.deselect = false;
if (tab.selected.count < 2) return;
var first = tab.selected(0);
var last = tab.selected(tab.selected.count - 1);
cmd.ClearFiles();
cmd.AddFile(first);
cmd.RunCommand('Select NONE');
cmd.RunCommand('Select FROMSCRIPT');
do {
cmd.RunCommand('Select NEXT');
tab.Update();
var item = tab.selected(0);
cmd.AddFile(item);
} while (item.name != last.name);
cmd.RunCommand('Select FROMSCRIPT');
}
Button as XML
<?xml version="1.0"?>
<button backcol="none" display="both" label_pos="right" textcol="none">
<label>Select Between Selected</label>
<tip>Select all items between the selection's first and last item</tip>
<icon1>#selectwild</icon1>
<function type="script">
<instruction>@script JScript</instruction>
<instruction>function OnClick(clickData) {</instruction>
<instruction> var cmd = clickData.func.command;</instruction>
<instruction> var tab = clickData.func.sourcetab;</instruction>
<instruction> cmd.deselect = false;</instruction>
<instruction />
<instruction> if (tab.selected.count < 2) return;</instruction>
<instruction />
<instruction> var first = tab.selected(0);</instruction>
<instruction> var last = tab.selected(tab.selected.count - 1);</instruction>
<instruction />
<instruction> cmd.ClearFiles();</instruction>
<instruction> cmd.AddFile(first);</instruction>
<instruction> cmd.RunCommand('Select NONE');</instruction>
<instruction> cmd.RunCommand('Select FROMSCRIPT');</instruction>
<instruction />
<instruction> do {</instruction>
<instruction> cmd.RunCommand('Select NEXT');</instruction>
<instruction> tab.Update();</instruction>
<instruction> var item = tab.selected(0);</instruction>
<instruction> cmd.AddFile(item);</instruction>
<instruction> } while (item.name != last.name);</instruction>
<instruction />
<instruction> cmd.RunCommand('Select FROMSCRIPT');</instruction>
<instruction>}</instruction>
</function>
</button>