File exists and dialog timer

I have some folders which were shuffled together and need tedious work to separate. I'm guessing there's a much better way to do this, but I'd also like to get more familiar with Dopus scripting....

Normally, selected files exist, but in a duplicate file collection, they may have been moved or deleted already.

This script opens 2 selected files paths in new tabs, "left" and "right"

How do I...

  1. Find out if they exist (selItem1.exists returns undefined)
  2. Make a dialog auto-close after 1s?


function OnClick(clickData)
	var qu='"';
	if (clickData.func.sourcetab.selected_files.count != 2)
		DOpus.Output( "Need 2 files" );

	var selItem1 = clickData.func.sourcetab.selected_files(0);
	var selItem2 = clickData.func.sourcetab.selected_files(1);

	if ((!selItem1.exists || !selItem2.exists)) 
		DOpus.Output("One of them does not exist");
		var  oDlg = DOpus.Dlg ;
		oDlg.message = "One of them does not exist " + selItem1.exists  + "," + selItem2.exists ;
		oDlg.title = "Compare Tabs Error";
		oDlg.buttons = "OK";
	clickData.func.command.RunCommand("Go " +qu+ selItem1.path +qu+ " NEWTAB OPENINRIGHT TABNAME " +qu+ "C1" +qu);
	clickData.func.command.RunCommand("Go " +qu+ selItem2.path +qu+ " NEWTAB OPENINLEFT  TABNAME " +qu+ "C2" +qu);


You wouldn't normally be able to select files/folders that don't exist. Are there some extra details that might be complicating things, like dealing with collections, or a filesystem that doesn't report changes or similar?

Exactly. So how do I determine if they do exist? And make a js popup with a timeout?

If you look at the item object documentation you can see it doesn't have an exists method, so that's why that didn't work.

FSUtil has an exists method you can use to test if paths exist. It also has a Resolve method which can be used to convert a collection item's path into a real filesystem path.

As for dialogs with timeouts, that's better as a separate question since it's not really related to testing if files exist. But the existing thread you bumped earlier should have the info you need:

Or the thread Jon linked to from that, which has example code:

If you can't understand any details of the examples or docs, ask in one of those threads and we can clarify. (Asking for the entire source code may not get a fast response, though, since that would take a lot more time than clarifying a particular detail that you're stuck on from the code that's already threre.)