Tip: Accessing/Editing Documents Outside of DEVONthink

A recent discussion in the DEVONthink To Go forum inquired about making available on Dropbox a sub-set of documents from a database where the documents are contained (imported) into the database. The documents need be available on Dropbox for editing/annotation in other applications/operating systems. Ideally, the external changes would then be updated in the database while maintaining the documents’ metadata and location/replication in the database.

The following workflow accomplishes these goals for me, but may or may not work for you, so first test on a small set of data at your own risk. I believe I posted something similar to this here in the past, but I did not go searching for it today. Feel free to discuss how it works, or does not work, for you along with any suggestions to improve the workflow.

  1. Create a folder on your desired cloud drive (e.g. Dropbox, etc.) and index this folder into your DEVONthink database (File menu, Index…).

  2. Create the following Applescript created by forum member korm, save it to your local hard disk. Name it anything you want-I’ve named mine Full Sync Indexed Folder.


on triggered(theRecord)
	try
		tell application id "com.devon-technologies.thinkpro2"
			deconsolidate record theRecord
-- synchronize record theRecord
-- The synchronize Applescript command was depreciated in triggered scripts beginning with DEVONthink 2.6.
-- Indexed groups are now synchronized automatically when selected in DEVONthink 2.6
		end tell
	end try
end triggered

  1. Attach the full sync script created above to the indexed group in the database by linking to the script in the group’s info pane.

In the future, when this group is selected 2 things happen. Any documents added to the group in the database are exported to the Finder cloud drive folder and any changes/additions that have been made to the contents of the Finder cloud drive folder are updated/indexed to the database.

  1. Now to put this into use, try the following. First, continue to tag and replicate documents in the database as needed as this group structure and document metadata will be preserved. To make documents available in the Finder cloud folder, replicate them to the indexed cloud group in the database. You could move them to the indexed group, but then you would have to manually move them back to the original location once you no longer need them on the cloud drive.

  2. Select the indexed cloud drive group in the database to activate the attached script. All the documents added to the folder have now been exported out of the database, into the Finder cloud folder. The documents can now be accessed outside the database, and the replicants in the database will still be active.

  3. Edit/annotate the document content outside the database as needed by accessing them from the cloud drive. You do not want to rename or move the documents as the link to the indexed group in the database will be broken. Note also that DEVONthink allows you to name documents in the database with characters that are not permitted in Unix and/or Windows file names (e.g. colon). The files in the Finder will be named automatically with legal names, so you will see a dash replacing a colon, etc. This will not create any problems when working with these documents, and the documents will not be renamed in the database (although it is a good practice to use legal Unix names in the database to begin with). I have no experience using documents on Android, so I don’t know what the Android OS file naming conventions are-you’ll want to research that yourself if trying this with the Android.

  4. Once you have edited/added documents that you want to be reflected in the database, select the indexed cloud drive group as described in step #5 and all the changes/additions will be added to the database.

  5. Once you no longer want the documents on the cloud drive, you need to change them from indexed to imported into the database. Right-click on them and choose ‘Move into database’ (you can first shift- or command-click on multiple documents to act on all selected documents at once). Confirm that the documents are now contained in the database as the indexed document arrow indicator should now dissapear from the documents.

For documents that are replicated in the database (i.e. the documents you worked with in step #4 above), you can now delete the documents from the indexed cloud folder. The replicants in the database will be preserved. For new documents added to the indexed group, you will need to move the documents to another location in the database. If they remain in the indexed cloud group, they will be re-exported back to the Finder indexed folder as described in step #2.

As an important note, when performing step #8 you must act on all the files in this indexed group before again selecting the indexed group’s icon. By selecting the indexed group, the full sync script will again be triggered and all documents in the group will be re-exported back to the Finder indexed folder. If this happens, you will need to start step #8 over again.

Thanks, Greg. (I know you posted this a while ago, but it must have been quite a lot of work.)

From DEVONthink version 2.6.x, it is no longer necessary to attach to groups the script that Greg mentions in steps 2 and 3 of his suggested procedure. DEVONthink now does auto-updating of indexed documents.

I edited the script some time ago to comment out the synchronize command as it does do nothing in a triggered script beginning with 2.6.x. The script can still have utility, as the auto-update feature that appeared in 2.6.x only indexes new documents from the filesystem into the database. If the user creates documents in the database that he/she wants to be automatically exported out of the database, then indexed back in, then the deconsolidate record command in the triggered script will initiate that process.

Having said that, I’ll confess that I no longer use this triggered script myself. It’s easy enough for me to send documents out to their indexed folders with the ‘Move to External Folder’ command, which then does make the script entirely obsolete.

Some of the folders that I index into DEVONthink are also used by apps that may add metadata about the documents with .plist files. I don’t want to see these files in DEVONthink, and the apps do not care if the .plist files are visible or not, so I hide them with a Hazel rule. Here is how it works, and as a disclaimer I have never lost any data using these rules, however one should test them first to see how they work in your environment.

In this example I am using a folder located at ~/Dropbox/Notebooks, and this folder is indexed into DEVONthink. The first Hazel rule is a ‘Go into subfolders’ rule so that Hazel will hide all .plist documents in all sub-folders of the Notebooks folder. The rule looks like this:

The second Hazel rule is the one that actually does the work, hiding all .plist files. The rule first tests to see if files are already hidden, as to not run on them unnecessarily.

Here is the code contained in the shell script.

find . -name "*.plist" -exec chflags hidden {} \;
exit

The user could, of course, modify the rule and/or create additional rules to hide any file names/extensions. Let us know how you are using it, or post any additional Hazel rules that you find useful when working with Hazel and DEVONthink.

Thanks for the tip, Greg!

Here is another Hazel rule that I use to help automate my paperless workflow of documents. In this example, every month I download via Safari my AT&T wireless invoice PDF to my Downloads folder. Hazel monitors the Downloads folder, and one of the rules checks to see if any documents contain my AT&T account number. Now my account number is not ‘0123…’, as posted in this image, but the ‘Name contains’ condition is where you would put the unique text string of the document that you want to test for.

Now this particular rule uses the very clever Hazel function DateMatch to find the invoice date in the PDF. Here is what the DateMatch token looks for in the PDF. The reason that the date string contains a hyphen in this example is because my current invoice contains the data ‘Bill Cycle Date: 03/22/14 - 04/22/14’ and I want the rule to locate and use ‘- 04/22/14’.

I also have Hazel rename the document using the invoice date. So, my AT&T invoice dated 4/22/14 will be renamed ‘2014-04-22-AT&T Statement’, because I now use this DateMatch token when naming the document.

I also add Mavericks tags to the document and move the document into a folder that I have indexed in DEVONthink. Now while I currently index all my documents, you do not need to do the same to take advantage of using Hazel with DEVONthink. You could have Hazel move the documents to a folder that has a folder rule attached to move the documents into DEVONthink, or index a single ‘Indexed Inbox’ folder in your databases and then move the documents into the database, etc. There are many options available to do this.

Finally, this rule gives me a system notification that the document was added successfully to my database. Enjoy!

Thanks for this Greg, it will prove useful for me and I have successfully implemented the date matching. You mention that it is possibe to create a Hazel rule that moves a date matched document to DevonThink unfortunately I can not work out how to do this :blush: I would be most grateful if you could please post an example rule that would achieve this? Many thanks in advance.

Hazel has a Move to Folder command, which appears in the first image on the post about Hazel above. Now I use indexed folders in DEVONthink, so this makes the process easy for me. For imported databases, you can have Hazel move the documents to the Global Inbox, located in ~/Library/Application Support/DEVONthink Pro 2/Inbox, or you could create folders and attach a folder action to them. DEVONthink’s folder actions are discussed on page 111-112 of the current DEVONthink Pro Office manual PDF.

Thanks Greg, much obliged. :slight_smile: