Searching based on parent group (folder)

Hi

I couldn’t figure out to search for all items that have a parent folder with a particular name. E.g. many of our folders follow a common structure. I’d like to search for all files that have an immediate parent group of “Burndown Reports”.

I couldn’t see the parent group or the file path listed under Help > Documentation > Windows > Main Window > Search Pane and Appendix > Search Prefixes . I can get the parent path out using AppleScript but there didn’t seem an immediately obvious way to search it.

There does seem to be a bit of a workaround, which is to treat groups as tags and simply search for tags; but that feels a bit drastic and I’m not sure if it might have other implicatoins.

Thanks,

Tom

A very short JavaScript solution:

(() => {
   const dtApp = Application("DEVONthink 3");
   const db = dtApp.databases["Insurance"]; // Use your database name
   const records = db.contents.whose({_match: [ObjectSpecifier().parents[0].name, "Burndown Reports"]});
   console.log(records().length);
})()

That just prints the number of records in “Burndown Reports” to the console in Script Editor (or if you run the script with osascript -l JavaScript filename.js from the command line). Depending on your needs, you have to add more code to handle the records.

1 Like

There is no location property for searches.
There is also not a parent property as a file can have multiple parents.

You can go into the Burndown Reports group and do a search with the scope set to the selected group.

You could also set up a local smart group in the database targeting this group.