Two-way sync with Dropbox?

Any scripting genius have a script that does a two-way sync between Devonthink and Dropbox? That means:

  • move new files in Devonthink to external folder in Dropbox
  • update the indexing of all files and folders in Dropbox
    …preferably script is triggered automatically.

Variations on this have been discussed before. This script, posted in 2012, doesn’t appear to work anymore:

	tell application id "com.devon-technologies.thinkpro2"
		set theRecord to the first item of (the selection as list)
		if the kind of theRecord is not "Group" then error "Please select a group"
		deconsolidate record theRecord
		synchronize record theRecord
	end tell
on error errorMessage
	display dialog errorMessage
end try

This request will be redundant when the new syncing tech is powering DTTG 2.0, but experience tells me not to wait for it. I’m not a fan of DTTG 1x, so a DIY Dropbox solution seems the best bet - if it can be done.

DEVONthink now automatically synchronizes index groups. The action your want is “deconsolidating”, which means transfering internal documents to the indexed folder and thus making them indexed. Or, as the DEVONthink dictionary puts it:

Here’s a triggered script that can be attached to any indexed group, it will deconsolidate. I wrote the older script you mention in the OP, but it no longer works because DEVONthink was upgraded and “synchronize” was deprecated years after I posted the first thread. “Synchronize” will also not operate in a triggered script any longer.

on triggered(theRecord)
		tell application id "DNtp"
			deconsolidate record theRecord
		end tell
	end try
end triggered

Thanks, Korm. I:

  • compiled the script in Script Editor
  • saved the script (to DTPOs Script folder)
  • attached the script to the folder I want to trigger indexing on. It has child folders.

Result: files aren’t copied to external folders, even when the script is applied directly to the folder I want to index.

Am I missing something here?

I suspect you are attempting to create a folder action script, when this script is a triggered script in DEVONthink. You want to follow the directions in the first post in this thread to attach the script to the indexed groups in the database.

Greg - no, I’ve set it up for a triggered script. Nothing is being triggered. I’ve tried to run the script manually, too, with no result.

The right-click “Move to external folder” command works perfectly, though.

In the thread you pointed to, there was this comment:

…leaving me somewhat confused. Does “indexed documents” refer to indexing one-way, as in Devonthink indexing folders it’s been pointed to, or does it mean two-way, and it also (supposedly) automatically shifts new files in DT to the external folder?

I’d certainly like to see this capability if it doesn’t already exist.

Probably. It works correctly over here.

Here’s the set up. Dragged “Eureka” into the test group, clicked the group, and the script triggered and deconsolidated. As you can see, “Eureka” is now indexed.

You have to click a group name to trigger a triggered script – they don’t operate on their own without the click. You could write a script to trigger itself every x-seconds, but that’s just uselessly burning memory cycles.

Damned if I know. My setup looks pretty much the same.

Screen Shot 2015-01-20 at 12.05.29 pm.png

Does the script apply to sub-groups in the hierarchy beneath the folder that has the script attached?

(Did the forum software just censor “d.a.m.n.e.d”? How quaintly Victorian. It obviously hasn’t been around the web much.)

Yes, but you have to click the parent that has the script attached. I just tried this – in Dropbox, made a child group in my test group. Sync’d in DEVONthink. Added a document in that child (a RTF created in DEVONthink), clicked the parent (where the triggered script is attached). The hierarchy deconsolidated, as expected.

Sorry – I can’t make this not work :unamused:

Clearly I have a talent …

Are we talking at cross-purposes? I’m OK with indexing files made in Dropbox. I’m coming unstuck when it comes to making files in Devonthink and then using the script to upload them to Dropbox.

Isn’t that what you started this thread wanting to do?


I’m fishing for why whatever I’m doing isn’t working. Can’t put my finger on it.

I just tested korm’s script and it works beautifully.

When attached to an Indexed group (via the Script field in the group’s Info panel) it is triggered when that group is selected/opened and moves non-Indexed items (including those in subgroups) out to the appropriate external folder, then Indexes them back into the DEVONthink database.

Neat. Of course, it’s not limited to folders Indexed from a Dropbox location. Can be a useful tool for those who do Index captures and wish to keep corresponding Finder folders in concert with the database contents of Indexed groups.

That’s what I’m after, but that’s not what’s happening, although the process should be straightforward. I’ll start from scratch later. I may have built in a glitch by using outdated scripts.

That might be a clue. I’ve seen cases where replacing one triggered script with another doesn’t take. Try removing the triggered script, closing then reopening the database, and adding back the script I posted.

I thought the problem might be that I keep my DTPO databases on a second drive I installed in the MacBook DVD bay when I upgraded with an SSD. I moved my main database across to the SSD, deleted the files I’d indexed in DTPO and reindexed them, restarted the laptop and then re-attached the script …

No result.

Then I rebuilt the database, deleted the script, restarted Devonthink, re-attached the script … still nothing.

The “Move to external folder” command works like a charm, indexing from Drobox>Devonthink ditto, but the “deconsolidate” script doesn’t take files from Devonthink>Dropbox. And that’s about where I’ve stopped.

Korm, Bill,

I deleted the script I’d been trying unsuccessfully to use, re-copied and re-compiled Korm’s script above, saved it to the ~/Library/Scripts/Devonthink folder (the earlier script was in the ~/Library/Application Support/Devonthink/Scripts folder), re-attached it to the Dropbox-linked folder in Devonthink … and voila! It worked.

No idea which of these steps cured the problem, but it all now Works As Advertised. Thanks for your support.

Probably a bad compile the first go-round. Script Editor can be flaky.

FWIW, I keep triggered scripts here – no magic to it, just easier to find

~/Library/Application Support/DEVONthink Pro 2/Scripts/Triggered