Collection Modified Date/Time

Neat! Indeed! :smiley: This one does the job!

I've already tried something simliar w/o success:

clickData.func.desttab.Update();

or

clickData.func.sourcetab.Update();

Thanks for your help!

OTH trying to code this script myself, I've learned a lot.

Thanks for your assistance!
Michael

1 Like

Hi

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.

Is there sthg. wrong in my script?

Thx,
Michael

Quick guess: Select ALLFILES doesn't add files to the list of files upon which the command object will act. Try SetFiles instead.

Thanks for your reply!

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:

clickData.func.command.setFiles(clickData.func.command.files);

Unless the above line is correct, it does not do anything at the very end.

Michael

You probably need clickData.func.sourcetab.files (instead of clickData.func.command.files).

YES! That one worked - thanks!

However, I had to adopt my code a little bit and move this line

clickData.func.command.SetDestTab(clickData.func.command.sourcetab);

down, so script is now:

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"); 
	}
}

So task solved with immense help :wink:

Thanks, Michael

NO! Too fast! Unfortunately did not work.

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.

So, basically I'm again at the beginning...

The last script still only calls Update() on the selected files.

(You may also want to check the count of selected dirs as well.)

Thanks, it works now!

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:

Michael

This should work:

if (String(clickData.func.sourcetab.path).substr(0, 5) == 'coll:')
1 Like

Thanks! This perfectly worked!