I tried to create version 2 of this script. Purpose: if previously no selection was made, the script should first update metadata of all files, remove them from collection and re-add them afterwards. Finally de-select files again.
While the script runs fine fo a single, marked file, it dos not work as expected when none file is selected.
I'm using this script:
function OnClick (clickData) {
for (var f = new Enumerator(clickData.func.command.files); !f.atEnd(); f.moveNext()) {
f.item().Update();
}
if (clickData.func.sourcetab.selected_files.count == 0) {
clickData.func.command.RunCommand("Select ALLFILES");
var sel = "X";
}
else {
var sel = "";
}
clickData.func.command.SetDestTab(clickData.func.command.sourcetab);
clickData.func.command.RunCommand("Delete REMOVECOLLECTION");
clickData.func.command.RunCommand("Copy HERE");
if ( sel == "X" ) {
clickData.func.command.RunCommand("Select NONE");
}
}
While executing the script, I can see all files in the collection being selected and finally being de-selected again. But the metadata is not updated, so does not the file's modification date in collection.
My knowledge of scripting, especially within DO's own objects is very limited.
Hence, I tried as you suggested to add the following command instead of Select ALLFILES:
function OnClick (clickData) {
for (var f = new Enumerator(clickData.func.command.files); !f.atEnd(); f.moveNext()) {
f.item().Update();
}
if (clickData.func.sourcetab.selected_files.count == 0) {
clickData.func.command.setFiles(clickData.func.sourcetab.files);
var sel = "X";
}
else {
var sel = "";
}
clickData.func.command.SetDestTab(clickData.func.command.sourcetab);
clickData.func.command.RunCommand("Delete REMOVECOLLECTION");
clickData.func.command.RunCommand("Copy HERE");
if ( sel == "X" ) {
clickData.func.command.RunCommand("Select NONE");
}
}
I just noticed that I'd selected one file and executed this script. So this way it did work correctly as always as the script used the alternative and no need to select all files within the collection first.
One small issue though: when executing the script upon a lister with currently no collection showing, DO throws an error "The operation is not supported by this VFS".
My script reads:
function OnClick (clickData) {
if (clickData.func.sourcetab.selected_files.count == 0) {
for (var f = new Enumerator(clickData.func.sourcetab.files); !f.atEnd(); f.moveNext()) {
f.item().Update(); }
clickData.func.command.setFiles(clickData.func.sourcetab.files);
var sel = "X";
}
else {
for (var f = new Enumerator(clickData.func.command.files); !f.atEnd(); f.moveNext()) {
f.item().Update(); }
var sel = "";
}
clickData.func.command.SetDestTab(clickData.func.command.sourcetab);
clickData.func.command.RunCommand("Delete REMOVECOLLECTION");
clickData.func.command.RunCommand("Copy HERE");
if ( sel == "X" ) {
clickData.func.command.RunCommand("Select NONE");
}
}
Is there a way to check if the active lister is currently showing a collection or not?
I had it already somehow working in a very early version of this script, however, I lost it. I think it was something with the folderpath, starting with coll: