Optimize adding to collection

While testing the scripting functionality to extract tags, I tried out adding some of the paths to a collection and noticed a massive slowdown.

Can adding files/folders to a collection, using the command Copy coll://MyCollection, be optimised ?

This would/should also help with the Everything tool integration, which writes all matches to a file and then uses DOpusRT.exe to import into a collection (with a noticeable delay for larger collections).

1 Like

I'm surprised if the DOpusRT.exe import method is slow, since it should be doing all the files at once (as long as they are all given to it at once, in a single listing).

Just retested Everything DOpusRT.exe approach and it does appear to be much faster, although there was a delay on first search with approx 1100 results (maybe due to some caching issue).

Rather than running a Copy FILE To Coll:// command against each file (which could certainly be slow)... can't you add the files you want to operate on to the Command.files script collection - then do a single Copy TO COLL:// command without any FILE arg specified? Not sure that will work - but I suppose that should be somewhat equivalent to batch loading a list of files from a text file. I shouldn't think calling the Command.AddFile() method for each file you want the command to operate on should take anywhere near as long as actually calling 'Copy' for each file...

That's definitely worth a try, and should work and be fast (at least in theory; I haven't checked it).

Good idea steje. I'll try it out and post back here if I'm still having speed issues

And depending on how you're getting the list of files... you don't even need to build the collection yourself.

If you're just going to operate on selected files when you execute your script function, then using any of the Command objects associated with the type of script function you're running may already have the files in the pre-filled collection. I.e. as opposed to using DOpus.NewCommand - which creates a new command object with nothing filled in. But the Func.Command object you get from other entry points should have an 'selected' files already in the collection:

Script Function: ClickData.func.command.files

Script Add-In::Script Command: ScriptCommandData.func.command.files

Script Add-In::Event Handler: (OnAfterFolderChange for example) AfterFolderChangeData.tab.selected||selected_files which you could then load into a new DOpus command object using the objCmd.SetFiles() method.