Recent folder list from a script

Is there a way to access the recent folder list from a script? I was expecting to find it as something like DOpus.recent, but no...

I can't see a scripting API for it but you can read the list out of %UserProfile%\AppData\Local\GPSoftware\Directory Opus\State Data\recent.osd fairly easily.

There was also a C API to get the list in the past, although I don't think anything has used it in a long time and I can't remember if it's still there. I can dig into that if it would be useful.

What kind of thing do you need the list for?

I'm writing a script to open a command prompt under various circumstances, and if the current tab is not on a drive path (e.g. Find Results), I'd like to open the command prompt in the most recent directory.
The file "recent.ods" is updated in real time? If yes, it will surely do the job.

There's a better way, if that's the aim. The recent list won't tell you which folder was most recently open in the current window. If other windows have also been active since then, they'll confuse matters by adding their paths as well.

Collections made by the Find tool store the initial folder they were started from.

Go to %UserProfile%\AppData\Roaming\GPSoftware\Directory Opus\Collections, open a .col file for a collection generated by Find, and see the relpath value near the end of the 2nd line. (AFAIK there isn't a way for scripts to query this more directly.)

(But also note that this value won't be there if the Find was done with multiple paths in the Find In path list.)

An alternative approach would be to look at the files in the collection to work out where to open a command prompt.

You could pick a directory from tab.backlist. If the current tab doesn't have any (e.g. because it's a Find Results tab), pick a better suited tab from lister.tabs. If the current lister doesn't have any, look for a different one in DOpus.listers.

But what exactly is the most recent directory anyway?

1 Like

Indeed! :smile:

Thanks to both of you for your ideas and highlights.
For the moment, I settled with:

  • the tab path if it is a drive path
  • else the most recent drive path in tab.backlist
  • else the most recent drive path in %UserProfile%\AppData\Local\GPSoftware\Directory Opus\State Data\recent.osd
  • else bail out

If this sometimes does things that are not what I expect, I'll try your other (excellent) ideas.