Any way to make find filter name="something" block till it finishes

I have a button that does this

Find FILTER NAME="Filter Name" RECURSE IN "G:" "H:" "I:" "J:" "K:"

it then tries to select the first file that it finds, but it seems that the find is asynchronous and the select happens, and then the find finds more files and so the select is buried somewhere down in the file list. Is it possible to make the find wait until it has finished before moving on?

Hope that makes sense.

Thanks

Taking a step back, what are you trying to do? There may be a better way than using Find and Select.

Essentially I just want to find any image files I have assigned a particular label to. They are somewhat scattered all over the place so I'm searching for them across all drives to gather them all up and display them in one lister. It basically works fine, the only nitpick being the asynchronous nature of find.

A script could do the same search (without using the Find command) without needing a lot of code, and could then open the list of files in the viewer, if that's the aim.

But where does selecting the first file come into things?

It's only for aesthetics and my own curiosity about whether it's possible really. This button searches for all files with a certain tag, goes into thumbnail mode, opens a viewer on the right hand side and it's just mildly annoying to me that the selected file and hence the image is now somewhere in the middle of the list.

I hadn't thought of scripting it.Thanks for the idea.

Can you give me a pointer as to how to open the list of files in a lister tab please, Leo? I've scripted finding the ones I am interested in but I can't workj out how to display the list. Thank you.

You need to add the files to a collection. This collection can be opened in a tab.

Could I trouble you for just a bit more detail please?

Certainly :slight_smile:

Here's a snippet:

var newColl = 'coll://MyColl-' + DOpus.Create().Date().Format('D#yyyyMMdd-T#HHmmss');
cmd.RunCommand('CreateFolder NAME="' + newColl + '"');

cmd.ClearFiles();

// add the files, e.g.
cmd.AddFiles(someVector);
// or
cmd.AddFilesFromFile(someFile, 'utf8');
// or
cmd.SetFiles();

cmd.SetDest(newColl);
cmd.RunCommand('Copy COPYTOCOLL=member');
cmd.RunCommand('Go PATH="' + newColl + '"');

Here's a complete script using this technique:

https://resource.dopus.com/t/find-duplicates-in-subfolders/44909

2 Likes

Very useful. Thank you.