Idea? 'All databases' in navigation sidebar

I sometimes wish it were possible to have a list of all my extant databases in the left hand navigation view. This is because I have several that are infrequently used, and in time they drop from the ‘Recent Databases’ menu. At that point, it feels weird to navigate to Finder, remind myself what I’ve got, and re-open a database from there. For some reason (to me) the DT’s UI doesn’t invite to think about its resources as reliant on Finder (I know that’s where the packages are stored, obv) – rather the app itself feels like the major repository of all things DT and so the single ‘source of truth’.

Anyway – I’d love to see an ‘all databases’ dropdown.

Or perhaps a refinement of ‘Recent Databases’ that retains every database ever opened, but perhaps reordered according to the last accessed db at the top?

Thanks for entertaining my notion!

Screenshot 2023-10-12 at 09.02.41

Look closer … and move the mouse over the “All databases” string (agreed, that is not what discoverability means, but it seems to be an Apple UI standard nowadays).

Not sure I follow you … but for clarity, the above was my mock-up :slight_smile: . Here’s the actual offering from the side bar:

Screenshot 2023-10-12 at 09.54.07

My point was that the ‘Recent Databases’ empties out in time, I think, if the dbs are not re-accessed – though I don’t know what that time window is (about a month?).

:upside_down_face:
I didn’t notice that, sorry. There’s “File/Open database…” (third entry in the “File” menu), and there’s a pop-up when you right click on the DT icon in the dock. Not sure if that helps or how fast/if at all those empty out.

1 Like

One possibility is also to add all databases to the favorites.

2 Likes

Try Script: Open or close databases

This is excellent, thanks!

Thanks – I use the Favorites heavily but am very selective as to what I allow in there (because too many entries = too much noise for my addled brain). They tend to be the 10 or so most accessed groups; as well as two often used tags (I love favouriting tags!).

@pete31 scripts may well be ideal for me.

One reason I asked is because I occasionally open all databases that I own in order to make backups with the ‘Daily Export’ scripts (on a 3-monthly and 6-monthly cycle, depending on use – these are the belt and braces additional backups to an otherwise robust backup plan ((yes, I’m quite neurotic about this)). Anyway – at that time, a quick way to view, or ‘open all’ database that I have quickly through the DT app itself, rather than digging through Finder, is really helpful. But I think that Pete 31 may have sorted me out.

Cheers, all!

That pop up is cool – and I didn’t know about it. I think it lists a (arbitrarily organised?) combination of open and recent databases.

What about adding a workspace just for this purpose? Workspaces remember the opened databases, window & tabs.

1 Like

That’s also a great idea, I didn’t realise that workspaces retain opened dbs. Thanks so much for all the solutions.

I guess DT just behaves as most apps on macOS: They do not remember which documents might pertain to it. That’s quite obvious in the case of Pages or Photoshop: You can store your documents/images wherever you want, there might be thousands or more of them, and there’s no point of the apps remembering what is where (or updating things when you move documents around or delete them).

The same goes for DT: It works with database “documents” which can be located anywhere on your disk (or on removable disk). You probably do not have thousands of databases, but the principle is the same: You can put them wherever you want (but a cloud location), you can move them wherever you want and you can remove them. If DT is not running at the time you do move or delete a database in Finder, DT can’t know what happened to it nor where it might be now.

That’s my go at explaining why an “All databases” entry is not possible and therefore not there. You might even see that as an advantage, as it gives you full control over your data – no silo that you can’t access but within DT.

I totally get what you are saying and you are right that this is how it works for most file types or ‘documents’. And the fact that nothing gets silo’d is a major reason I’ve entrusted my life to DT!

I guess I conceptualise DT slightly differently than Photoshop or Microsoft Word. Because a DT database is explicitly NOT a document in the way of a single jpg or docx, and we are strongly discouraged from rummaging within the package files.

I sort of think of DT as, itself, the entire database - the application within which all the data is held. I guess in the same way that Apple Photos or Music does, in fact, retain a record of all your constituent photos or songs, and then provides a breakdown of that data: albums, playlists, whatever. I know you can store photos or mp3s elsewhere, but once opened/added, it’s without the single library.

In my (perhaps erroneous) view DT offers a sort of doublethink, in that databases are both “documents” independent of the application, but themselves contains tens, hundreds, thousands, of documents again.

Anyway – maybe this is all just quibbling over semantics :-). I could see a real case for ‘All Databases’, or at least, a ‘Recent Databases’ list that never empties its memory. But the workarounds offered above serve me well, too.

Thanks for your thoughts @chrillek!

Not to burst the bubble, but a docx is is by no means a “document” – it’s a compressed folder. As are, BTW, Pages and Numbers “documents”. Apple’s Finder makes you believe that they are something else.

They are silos. Try finding your pictures in Photos nowadays :wink: (It is possible, but they are very much not in the file system per se).

Nevertheless, here comes the fun part. I wrote a small script that finds all unencrypted databases (i.e. those with extension dtbase2) on your disk (and possible connected external drives, if they have a Spotlight index). It then shows you a list of these databases from which you can choose those that you wish to open.
The script can be run from within DT or from Script Editor or with osascript on the command line.
Most of the relevant code has been shamelessly stolen from Cedric Owens’ Medium text – great stuff!

ObjC.import('CoreServices');
ObjC.bindFunction('CFMakeCollectable', ['id', ['void *']]);
(() => {
  const databases = {};
  /* Find databases by magic content type */
  const queryString = `kMDItemContentType = "dyn.ah62d4qmuhk2x43dyqmu1g3mw"`;
  /* Build spotlight query and execute it*/
  const spotLightQuery = $.MDQueryCreate($(), $(queryString), $(), $());
  if ($.MDQueryExecute(spotLightQuery, 1)) {
    const resultCount = $.MDQueryGetResultCount(spotLightQuery);
    /* fill the `database` object: keys are the db name, values the path */
    for (let i = 0; i < resultCount; i++) { 
      const mdItem = $.CFMakeCollectable($.MDQueryGetResultAtIndex(spotLightQuery, i));
      const itemPath = getMdValue(mdItem, $.kMDItemPath);
      const displayName = getMdValue(mdItem, $.kMDItemDisplayName).replace(".dtBase2","");
      databases[displayName] = itemPath;
    }
  }
  const app = Application("DEVONthink 3");
  app.includeStandardAdditions = true;
  /* Display a list of database names to choose from */
  const selectedDB = app.chooseFromList(Object.keys(databases).sort(), 
    {prompt: "Select databases to open", 
      title: "Available databases",
      okButtonName: "Open",
      cancelButtonName: "Cancel",
      multipleSelectionsAllowed: true,
      emptySelectionAllowed: false
    });
  /* If the user did not cancel the selection dialog, open all selected databases */
  if (selectedDB) {
    selectedDB.forEach(db => app.openDatabase(databases[db]));
  }
})()

/* Helper function to return a value from an `MDItemRef` as JavaScript value.
   Note that the `MDItemRef` must have been made into a `CFCollectable` */
function getMdValue(item, key) {
  return ObjC.deepUnwrap($.MDItemCopyAttribute(item, key));
}

Possible problems with this approach:

  • It does not work with encrypted databases. That should be easy to fix by modifying queryString appropriately
  • It will not work with identically named databases. I.e. if you have “myDB.dtBase2” in “…/folderA” and “myDB.dtbase2” in “…/folderB”, only the one found first will be shown. That’s also fixable, but requires some more work.
1 Like

It’s a document (just like .rtfd is) but not a file. Sorry, couldn’t resist :wink:

3 Likes

And right again …

I do the same sort of, but I do just go to file > open databases. It shows all the databases you have and if you click and drag you can select all of them to open at once. (I’m not sure that would be wise if you had millions, but I have 5 or 6 and it works fine.)

1 Like

No, it doesn’t. Try creating a new database in another folder, ie not the same as all your other databases. Then use File > Open database

That is admittedly an edge case, as most people will probably put their databases in the same folder. But some don’t (e.g. using removable disks).

genius, that had never occurred to me to do!

Didn’t even know you could do that :rofl:

1 Like