I was hoping that I could avoid looking at that script… In order to make it easier to understand, I quote the relevant part here:
Your first point of reference in this case should be the scripting dictionary for DT. Open the Script Editor, go to the “Data” menu and choose its fourth entry. Select DEVONThink 3 from the list of programs. Search for “export”… Well: the return value is of type text
. No idea what it might contain (and why an export method even returns a value other than a boolean to indicate success or failure). Since the script quoted above ignores the return value (it just saves it in a variable that is never used again), why would you even care what it is?
Also, when you read the documentation on the export
method in the function library, you’ll see that it unconditionally exports everything below its starting point. So when you call export
on a database, there’s no chance to compare modification dates etc. before the fact. It’s an initial backup, not a delta one.
But as a “seasoned C++ programmer”, you should manage to read some basic text on another current programming language and get the gist of it, I guess. After all, JavaScript is a lot simpler than C++: No real inheritance, no templates, no operator overloading … And for JXA scripts, you do not even bother with object orientation at all: its all about arrays method calls. Why not give it a try?
One suggestion:
- First of all, start afresh. The script quoted before does not help you with what you want to do
- Second, loop over all
databases
- Inside the loop,
- get the corresponding folder on your disk as a starting point (# 1)
- loop over the
content
. That’ll iterate over all records in this database - now, for each record
- if its
type
is group- check if a group with the
name
of this record exists in your current folder and create it if not - recurse to #1
- check if a group with the
- Obviously, you have a normal record (i.e. no group). Get its
name
property - if a file with this name does not exist at the current location, create it and copy your current record to it (possibly using the record’s
path
property and the shell’scp
command) - else check if the record was modified more recently than the file (using the record’s
modificationDate
and the file’s last modify date, probably with a shell command)
- if its
- Inside the loop,
As I said: Maybe it is easier to do a complete export of your database(s) in regular intervals