Devonthink Pro Office - Indexing Files Sync

I have indexed my folders pointing DT to Level 0 for example:


Adding Files
Desktop Folder - Adding folders / files at levels 1-3 = sync to DTP database = ok
DTP Database - Adding folders / files at levels 1-3 = sync to Desktop Folder = change not replicated in Desktop Folder

Is this correct? I was hoping for 2 way sync if possible

It is correct-documents in an indexed folder in the Finder will auto-update in DEVONthink, but documents created in DEVONthink in an indexed group will not automatically be exported out of the database to the indexed folder in the Finder. The thinking here is that you may want to mix documents in an indexed group-say index PDFs that you want available to other apps while keeping annotation documents in the same group, but available only from DEVONthink.

You can somewhat automate 2-way sync by attaching a triggered script to the group in DEVONthink.

on triggered(theRecord)
		tell application id "com.devon-technologies.thinkpro2"
			deconsolidate record theRecord
		end tell
	end try
end triggered

When you attach this script to indexed groups in DEVONthink, selecting the group (to activate the trigger) will export all database documents (and sub-groups) in the group out to the Finder.

Thanks Greg,

I’m complete new to the scripting so not sure how to complete this. Do I paste in into Apple Script Editor, save it then assign in into DTP Scripts? Possibly not because you say to attach it to the group but I’ve right clicked on the group and database and cannot see anything about adding/editing scripts in there.

Lack of script experience on my part.

Paste into the Script Editor, then save the script somewhere other than the DEVONthink scripts folder(s). The script cannot run stand-alone as it only works when triggered (when a group is selected), so there is no reason to have it available from a script menu.

Then select an indexed group, show the info pane for the group, click on the Select… button and navigate to the saved script. That’s all there is to it.

As a time saver, you can command-click on multiple indexed groups to apply the script to all of them at once.

Thank you. I’ve saved the script under User-Library-Script and assigned path within DTP group folder.
Still only syncing 1 way though (iMac to DTP). Tried changing “theRecord” for the folder name but made no difference so a bit stuck now.

Screen Shot 2014-06-03 at 13.53.57.png

Does it need to be in a specific Script folder like User, Computer, etc for it to work?

  1. The script can be anywhere on your Mac, even on the desktop.

  2. You do not want to change anything in the script. However, to make it compatible with a future version of DEVONthink, you might want to make this change to the ‘tell application id’ line:

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

This change has nothing to do with what you are encountering now-the script will work fine as originally posted.

  1. The images that you posted indicate that there is not a script attached to the group in DEVONthink. A group with an attached, triggered, script will have a script icon displayed.

In case my earlier description was not clear, the script is attached to the indexed group within DEVONthink’s Select button, not through the Path field.


Top folder with script.png

All folder with Script.png


Hi Greg, Aforementioned is what I have now. What seems to happen is I can add new groups within DTP and these are synced to iMac folder. Transferring groups to groups does not sync to iMac for me and produces the Error attachment for some reason?

Example new items sync.png

Sorry, could not attach this to previous message.

I’m not sure what would cause that-can you reproduce this behavior? Were all the sub groups created in DEVONthink, or were some created in the Finder?

As a suggestion I would try not attaching the script to sub-folders of groups where a parent group has the script attached. Meaning, if you attach the script to group 0, all the sub-groups will sync when the script for group 0 is triggered. In the past I’ve attached the script to multiple levels as you have done without problems, but the script does take some time to execute so they can slow you down if the script is acting on groups with hundreds of documents. Also, when transferring groups, I personally make sure that any indexed groups are moved into the database before nesting as a sub group of another indexed group.

Screen Shot 2014-06-03 at 15.37.39.png

Managed to reproduce the error this time with script only at level 0 (parent folder level).

Created this as a test database, generated initial folders 0-5 within Finder and indexed. Also tried by generating Groups within DTP and error reproduces.

If its woking at your end it must/could be some thing local to my iMac but I don’t know what it could be. The script works for new folders generated in DTP and generates a folder to iMac documents. Another error occurs when I move any of these Finder folders which generates a duplicate within DTP, see folder / Group 5 below showing 2 Group 5 folders (Finder on left is should be correct structure);

Screen Shot 2014-06-03 at 15.50.02.png

Beyond me

That is to be expected. You cannot move folders in the Finder that are indexed in the database without problems as DEVONthink cannot (yet) find them to reconnect. This is a know limitation that many of us have requested be changed, for some time now. Here is one thread on this that was posted just yesterday link. One thing that you can do to overcome this in most situations is to move the indexed folder into the database, move it inside another indexed group in the database, and then when the script is triggered the group will be exported back out as an indexed folder in the Finder, in its new location. More trouble than should be necessary to deal with this, but it does work.

Does the triggered sync script work as expected if you do not move any folders in the Finder?

I seem to have the opposite where moving Finder folders works but moving DTP with the script does not;

Finder - generate folders 1-5
DTP - Indexing folders 1-5 = ok
Finder - rearrange folders 2-5
DTP - collapse & expand database = no shadow files (if thats what they are called) and DTP files align with Finder folders 1-5
Finder - add files into folders 1-5
Finder - move folders 1-5 and files individually
DTP - collapse & expand database
DTP files align with Finder folders 1-5 :smiley:

Check if sync file error reproduces when file generated in DTP rather than Finder
DTP - generate folder 6
Finder - move folders 1-6 and files individually
DTP - collapse & expand database
DTP files align with Finder folders 1-6 :smiley:

Assign Script to DTP folder 1-6 and check movement errors
Finder - move folders 1-6 and files individually
DTP (Note :bulb: ) = Scripts removed from DTP automatically = possible cause of problem :question:
DTP - collapse & expand database
DTP files align with Finder folders 1-6 :smiley:

Reassign lost Scripts to DTP folder 1-6 and check movement errors
DTP - move folders 1-6 individually
DTP (Note :bulb: ) = Scripts remain in place
DTP - collapse & expand database
DTP files do not align with Finder folders 1-6 :frowning:

Current summary
Indexing DTP with Finder folder and moving Finder folders below level 1 external of DTP works for me = DTP and Finder Folder & File alignment.
I would prefer to work within DTP but probably best I avoid moving folders and files within DTP until I get the script working properly. Tested editing sample documents through the DTP interface and using Preview as external editor and these edits/changes replicated ok.

The script is very basic, as it does only one thing. When triggered, if the indexed group has internal records (documents and/or sub-folders), export them to the indexed group’s folder in the filesystem (Finder)*. There really isn’t anything to debug/troubleshoot to get working properly, and I’ve never seen DEVONthink remove any attached script from a group. I also used a more complicated version of this script (included sync and deconsolidate commands) for a very long time on all my databases. I only stopped using it when the sync command was incorporated into DEVONthink. See the pinned topic at the top of this forum here. I have to believe that there is something else creating a problem here, but I’m at a loss as to what to suggest you try.

*From the DEVONthink script dictionary:

deconsolidate v : Move an internal/imported record (and its children) to the enclosing external folder in the filesystem. Creation/Modification dates, Spotlight comments and OpenMeta tags are immediately updated.
record record : The record to deconsolidate.
→ boolean

Hi Greg,

I’ve had another go and still getting the same problem so going to park it for another day. Nothing lost though as I’ve learnt a little about implementing a script which I had not done before :slight_smile:

Do you know if there is a script for syncing tags with finder files that have been indexed so if I work either within DTP or Finder and add tags they sync between both locations :question: I think this is only a problem when indexing rather than fully imported local DTP databases.

My experience is, that on Mavericks, nothing is required to keep the tags in sync beyond selecting the indexed groups which updates the tags/documents in the index. It used to be (perhaps still is the case) that DEVONthink did not write out OpenMeta tags to the filesystem unless the document was moved into the database, then moved back to the external folder. However, with Mavericks tags a change in tags from DEVONthink is immediately reflected in Maverick’s Finder tags.

If you want to update all indexed items across all databases at once with a script, there is one available from DEVONthink. Select the menu Help>Support Assistant, then from the pop-up window Download extras>Update Indexed Items. The script will be installed in the Data folder under the DEVONthink scripts menu (between Window and Help).

By default, this script only updates indexed documents or groups located at the top level of the database. See this version of the same script that will prompt you whether you want to update indexes at all levels of the database.

Thanks for that. I’m not at the iMac but will check when I get back. It may have been an old document I read about tag sync issues when indexing so happy days if it works for Maverics. Groups / file structure is there and I’m looking into tagging so want to reduce any potential problems. Once it’s all taged I will look into syncing tags from iMac to Windows PC, probably through a cloud although I’m not sure if additional software is needed for this or if they sync ok.

Got round to checking and tags are being synced fine so thats good :slight_smile:

I’m having the same problem with this script which suggests I’ve either implemented it wrong or there is something else on my iMac causing the problem but I cannot think what because everything is pretty standard.

To check I’ve done this correct this is what I’ve tried:
Install scripts external of DTP
Attached script to DTP groups/folders (high level and all combinations tried)
Not combined any off the scripts and only installed / ran them individually

I take it this should work but for some reason I’m going around in circles with this :cry:

Because this may be something local on my machine I want to check the application ID is correct and I’ve not amended it in the past somehow. How do I check ```