Syncing Scripts, Smart Rules & Smart Groups

Has anybody set up a mechanism (I’m thinking e.g., Chronosync) to synchronise scripts, smart groups and smart rules across 2 macs? I was thinking of a folder on iCloud which Chronosync on both devices would independently sync to, meaning changes would be propagated from one device to another. Any thoughts on that? I’d be reinstalling Chronosync only for this task, and I’m sure the shell offers some kind of copy if newer function which I could call from a script and do the whole thing from within DT. What happens to DT if its plist-files change whilst it is open…?

(And yes, I’d really like this to be a feature integrated in DT.)

I’ve not done, but should be do-able (unless cross machine copying messes machine-specific information). Chronosync, rsync, and others could handle, I suspect. Do you have a full list of the target folders to be replicated?

Basically it would be

  • /Users/username/Library/Application Scripts/com.devon-technologies.think3/
  • /Users/username/Library/Application Support/DEVONthink 3/imprinter.data
  • /Users/username/Library/Application Support/DEVONthink 3/SmartGroups.plist
  • /Users/username/Library/Application Support/DEVONthink 3/SmartRules.plist

There’s no machine-specific info in these files to my knowledge; I have previously copied them manually without any trouble. When doing that, though, I have always closed DT on both machines first; if this is to go ahead with any kind of automation, then DT won’t be closed at the time the files are copied (shouldn’t be a problem) or replaced (may be a problem for the plist files; scripts are cached). For my purposes it would actually probably be sufficient to do this one-way, that is from my iMac to my MacBook.

I have a number of house-keeping scripts which run daily on DT; I have previously always deactivated these on the MacBook, because I had observed the MacBook doing the house-keeping (say moving expired files to trash) and then the iMac doing the same on awaking (because the databases weren’t yet synced); typically a sync would kick off at the same time, and I was never sure what would happen if sync and a script tried to move a file at the same time… There doesn’t seem to be any way I could automatically remove (or deactivate) a smart rule via script, though (@BLUEFROG is that correct?).

I’m sure syncing smart rules and groups has been requested as a feature before, and I understand that it would not be desirable in all environments (imagine a team of people using DT with the same database but different missions). So for sure it would have to be a an optional feature; and probably one to be selected for each and every smart rule/group (e.g. via a selector in each smart rule/group settings window).

1 Like

Been doing a bit of thinking on this. Assuming that it is ok to simply copy these files from one machine to another (without messing up DEVONthink) the issue is to find a way to reliably copy the files from one machine to another.

Picking up on the your ideas, @Blanc, to use Chronosync (or other software that on schedule or detected change) to copy from one place (source) to another (target)

The issue then is where the “another” target place is and how connected. Ultimately that could be the same-named folders on another machine. Do it directly and automatically would mean that there would need to be a network connection between the two devices. In the Mac-world that is possible to connect machines with what they call “file sharing” with SMB or AFP protocols. That would of course, work but requires that the two machines are actually connected on the network when the source machine launches the copy. That’s not always the case even when the target machine is turned on.

So it seems to be a better design would be for the source machine to watch for changes (Chronosync, Hazel, or even initiate manually with terminal command or Apple Script), then copy into a shared place accessible by both machines. I think that place could be a Dropbox folder (or iCloud, or Google Drive, or whatever) on the source machine. In due course files in that folder synch “up” to the cloud.

Then, when the target machine is turned on and connected to the network the cloud services will sync the files down to the local folders on the target machine. It would be the very latest versions as put there by the source machine.

On the target machine, before DEVONthink starts there would be a automatic (Chronosync, Hazel, or script launched manually) that would detect the changes and the copy the files into place for use by DEVONthink when it eventually starts.

While I have an use Chronosync, I think a better tool for this would be Hazel–but Chronosync can also work for this as it can launch on detecting changes to the files.

I HAVE NOT SET THIS UP OR TESTED. JUST THINKING THROUGH A DESIGN.

The setup could be using Dropbox (my preferred cloud service) with a new folder called “DEVONthink Stuff” with two subfolders to that:

Watch folder:
“/Users/username/Library/Application Scripts/com.devon-technologies.think3/”
and on change copy folder and files to
“/Users/username/Dropbox/DEVONthink Stuff/Application Scripts/”

Watch folder:
/Users/username/Library/Application Support/DEVONthink 3/"
and on change copy files:
imprinter.data, smartgroups.plist, and smartrules.plist"
to folder “/Users/username/Dropbox/Apps/DEVONthink Stuff/Application Support/”

The on the target machine, do reverse. Look at the Dropbox (or other) files/folders with [Chronosync, Hazel, or manual] and upon change copy them into place for DEVONthink to use.

Something like that. All this is fiddly and needs to be exact and I might have made a typo … but just design phase now. And yes, could be built in to DEVONthink (adding to their very long list of “to-do” items!!)

I don’t have a great need for this sort of thing as I don’t have a lot of automatation setup that needs to be replicated across machine. I rely on my iMac’s version of DEVONthink to do all this work, and the MacBook version of DEVONthink just works with the results via synch.

1 Like

Thanks for all your thoughts; they add to mine. Thanks especially for suggesting using Hazel, which I do have installed. Presumably this would use a Date Last Modified is after Date Last Matched condition on the source and the reverse on the destination (that is assuming one way sync via an intermediary such as Dropbox)?

That is what I used to do; because I automate quite heavily nowadays that means that things build up in my inbox when I’m away from my iMac and using my MacBook instead. It is in my nature to dislike anything sitting in my inbox (in that it is work which needs to be done, and is therefore best done now) so not having the same automation available ends up irking me.

I admit a bit of irking is not really a problem all things considered; but I like a challenge :wink:

Yep. But on the target it is not reversed. It is still from the Dropbox to the local file system. I guess if you make changes on the target to go back then… When syncing I guess I would be partial to Chronosync. Trying not to hurt my brain.

That is correct.

Also, I’d say it’s inadvisable to synchronize property list files to a machine with DEVONthink open on it.

I thought it might be… :exploding_head:

@cgrunenberg can also weigh in on this. I personally wouldn’t suggest it.

This might cause unexpected issues indeed (e.g. not synchrinizing as expected or losing changes).

If DEVONthink not running on when these files are copied or updated, would it lead to issues? I wouldn’t be surprised if it might; just trying to flush out the issues. E.G. Sharing things like that.

It shouldn’t.

So … with the information that if DEVONthink not running to copy from source, and DEVONthink not running when copying to the target, then I think I’d start with using Hazel as the tool to copy to/from the shared file space (Dropbox or other synced cloud) when DEVONthink not running. Hazel has configuration rules that a condition is that “passes AppleScript or JavaScript, or shell script” which per their documentation relates to the return codes. So that could be configured to protect against copying when DEVONthink running.

Food for your thought.

Oh, very nice :slight_smile:

if application "DEVONthink 3" is not running then return true should be requisite line of code. I’m actually going to copy from source with DEVONthink running, I think - but will only copy to destination when DT3 is closed.

I’m doing the same with Mail scripts btw.; Mail actually syncs its rules, but doesn’t appear to sync the activation status at the same time; nor does it sync the scripts which the rules call. Both those things can be copied using the same mechanism as for DT though - I’ll report back when I’ve finished setting it up :slight_smile:

Wasn’t in my “design” above (simply because it didn’t occur to me), but remember in Hazel you can use a “nested or” to check for change in any of the three files of interest in the Application Support folder… You probably knew this, but I’m mentioning anyway.

1 Like

I apologize for barging in here… What about

  • get DT state “is running”
  • if true, quit DT
  • do your stuff
  • if state is true, start DT again

Assuming that “quit” is possible in scripts. That way, you do not have to bother. I’d add some wait time after the quit command, just to be sure.

@rmschne I did, thanks :slight_smile:

I’ve set everything up, it even works. Well, it would work, if iCloud reliably reflected changes made on one device on the other device. My iMac uploads a file, my iPhone and iPad are aware a file has been uploaded - just iCloud on my MacBook sits there, quite oblivious to the fact that there is a new file. Perhaps I should try OneDrive.

@chrillek: that would be possible; but DT won’t be able to automatically restart and reload my databases, because they are individually password-protected (I posted my reasons for doing that some while back, somewhere in the depths of the forum), so I can’t automate that.

I like and use Dropbox as it “just works”. It does something fancy when both devices on the name network to copy that way before uploading. Fast and reliable. I find Google Drive works pretty fast, but I don’t use it much. I have One Drive and never use use it. I avoid Apple Cloud except for those apps which like it.

If you can count on iMac and MacBook being on the network, bypass the Cloud idea and just use the shared folder connection (SMB or AFP).

Unfortunately, Apple is a lot better with the marketing for iCloud than with the code for it. I switched away from it to my NAS wherever possible. That simply works (and has the added benefit of no marketing blurb)