Recent Databases

Try this one, sjk. ```
(* Select DTP databases to close: close their windows and then close them
*)
tell application id “com.devon-technologies.thinkpro2”
activate
set _names to name of every database whose name is not “Inbox”
set _choose to (choose from list _names with prompt {“Choose DBs to close.”} default items “” with multiple selections allowed)
if _choose is false then
return
else
repeat with x in _choose
close (every viewer window whose name is x)
close database x
end repeat
end if
end tell

Thanks! I’ll have to set up some new dbs to test with since I don’t want to accidentally disrupt certain retained window layouts for my current ones …

Trouble is that if you close a window before closing the db currently viewed in it, as your script does, that window layout is no longer retained for the db to use when it’s (the db’s) reopened. A partial workaround is to close the window after closing the db, assuming you don’t care about the layout for the db content that temporary replaces it (a misbehavior I absolutely abhor).

If that doesn’t make sense I’m now blaming it on being so (*!@#$ messed-up that I can’t explain it clearly. :imp:

Thanks “twicks”, “SJK”, “sampler”,

The Startup preference setting was indeed the problem. I just never equated “Open windows that were open on quit” with opening databases that were open on quit. I always keep my databases displayed in a single window and just select the one I wish to view at any given time. Somehow this setting must have changed either with the Snow Leopard update or perhaps just a new beta install of DTPO. For me, all is back to “normal” now.

I would still like to see the developer pursue a more convenient way to individually “Close” selected databases with DTPO remaining open.

Thanks to everyone who has contributed on this thread, it has been both informative and helpful!

Here’s one that closes the DB before closing its former windows.```
(* Close selected DBs Version 3
Select DBs, close them, and then close the windows that contained them
*)
tell application id “com.devon-technologies.thinkpro2”
activate
set _names to name of every database whose name is not “Inbox”
set _choose to (choose from list _names with prompt {“Choose DBs to close.”} default items “” with multiple selections allowed)
if _choose is false then
return
else
repeat with x in _choose
set _wids to “”
set _wids to (id of every viewer window whose name is x)
close database x
repeat with w in _wids
close (every window whose id is w)
end repeat
end repeat
end if
end tell

Hmm, only I’m being YELLED to? :slight_smile:

An easy mistake since it’s a v1 preference that hasn’t been v2-ified.

Wow, that’s impressively restrained usage. :astonished:

I can’t imagine using DTPO without multiple windows open, viewing different groups within one or more open dbs.

Glad to hear it.

At least in the short term selecting multiple dbs (e.g. to close them) may remain in the realm of scripts like sampler’s, although I can imagine how multi-db selection in the sidebar for running certain actions could work. I think DTech has stated that sidebar functionality is still incomplete; it seems that way (and kind of “sloppy”) to me.

You’re welcome.

Neat. I’ll give it a try first.

Edit:

That works great! It also solves the problem (bug?) with File > Close Database not being active when there’s only a window with Inbox being viewed. If you select an open db in the sidebar of that window (replacing the Inbox view) and close it (restoring the Inbox view), then File > Open Recent > db will create a new window for db that overlays the Inbox window (ouch). Close db again and now you’ve got two overlayed windows viewing Inbox (ouch). And the previously retained window layout for db at the non-overlayed location has been replaced (sort of?) with the Inbox-overlayed one (ouch)… until you close the db while it’s being viewed in a window at some other location (usually?). The “sort of?” and “usually?” questioning comes from sometimes being surprised by File > Open Recent (or New Window) opening with a previously retained window location that had been temporarily lost. These patterns of properly and misbehaving saved/lost window states, sometimes but not always predictable, are an endless usability fiasco for me.

Lesson learned: be careful how/where you close a db if you want its next new window to open where you want/expect it to.

I’m happy that the script is useful. Here’s a variation that closes every open DB before its windows and then quits DTP. Feel free to modify it. ```
(* Close all DT Databases and quit DT
This script closes each open DB,then closes the DB’s former windows, and finally quits DT.
-sampler
*)
tell application id “com.devon-technologies.thinkpro2”
activate
set _names to name of every database whose name is not “Inbox”
repeat with x in _names
set _wids to “”
set _wids to (id of every viewer window whose name is x)
close database x
repeat with w in _wids
close (every window whose id is w)
end repeat
end repeat
quit
end tell

That’s a handy alternative to regular quit if you want the next launch to only open an Inbox window when the “Open windows that were open on quit” is set.

Thanks again for writing these scripts.

Wow! I think this just fixed my issue. I had my system preference set to 10, I switched it to 30 and now all my DevonThink databases are listed - fingers crossed this solves the issue permanently! :smiley:

Thanks!