Automatic move to external folder?

Hi! In DT I index some folders I have in Dropbox. When I add a new note in DT, the file is first placed somewhere in DT’s file system. I have to use the command “Move to external folder” to get DT and Dropbox in sync again. I tend to forget that sometimes. Is there a way to automate the process via a script?

Attach this script to a group. It will move every internal document in that group (and its children) to the target external folder. The group has to be clicked - to trigger the script - for this to happen.

To do the opposite (move everything internal) change the “deconsolidate” verb to “consolidate”, in the script.


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

It’s also worth mentioning that you can attach only one script to a group. If you are already using the Synchronize script to update the indexed folder’s documents in the database, you’ll need to decide which script is most useful to you.

Or … use this version which does both synchronize + deconsolidate :wink:

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

Triggered scripts are not limited to single actions - they can, in fact, be quite complex.

I knew you would find a way! :slight_smile:

Wow, thanks a lot! Perfect! :smiley:

Pleased to be a help – if the results seem odd, try the script by flipping the “synchronize” and “consolidate” statements. I suspect there are cases where the order of execution matters. Just be sure to use Scripts > Update Scripts Menu whenever you modify a script, else DT doesn’t “see” the change until the next time it is launched.

Hi Korm,
I’ve tried your script and it’s very useful. What do you mean by

I’m asking because I use it to bi-directionally sync a dropbox folder and what I noticed is that if I delete a file inside Devonthink changes are not reflected in the finder. I tried changing the order of the two actions but nothing changes, is it expected? do you think there’s another way to have this change to be reflected in the finder? The first use of indexing in DT for me is to clean up the mess of duplicate files in the dropbox folder (it is a shared folder…) and the ability of DT to recognize duplicate files is very useful to me… :confused:
thanks
Nestor

Are you emptying the trash in DEVONthink? If so, you will get a dialog to confirm how the documents should be deleted. Choose ‘Files’ or ‘Files & Folders’ if you want the documents deleted from the indexed Finder folder.

Auch!!
Thanks a lot that did the trick :blush:

This script is exactly what I’ve been looking for, but I’m having a little trouble with the DTP indexed groups to Folder part of the action. Any ideas why, if I create a new sub-group in DTP it adds the new DTP sub-group to the Indexed ‘real’ folder correctly, but it does not add any files that I have move into that sub-group in DTP to the actual ‘real’ sub-folder that was created. Thanks.

It works here. Did you select the top level, indexed folder in DEVONthink (the one with the attached script) after moving files to the sub-group? The script only runs when the group it is attached to is selected. Moving documents to the group, or selecting just the sub group will not.

Yes. I do try selecting the top level Group which has the script attached after each change. I am using a test folder which has 49 files of various type (mostly pdf’s). What I have found is:

  1. The sub-groups are always handled correctly whether they are added/deleted in either DTP or the actual file structure, the change is correctly reflected in the corresponding location.
    However, handling of the actual files within the groups/folders is inconsistent:
  2. When a file is moved in the folder it is usually moved correctly between groups in DTP.
  3. If files are moved in DTP the change is NEVER reflected in the actual file folder structure.
  4. If a file (like a rich text file) is created in DTP the file is correctly added to the ‘real’ file folder.

I am always selecting the top group which has the script attached between and changes/tests. Any suggestions would be appreciated. I would love to get this working. Thank you.

Do you mean files that are already indexed? If so, that is the expected behavior. If you have indexed files, you can move them or replicate them into any group in the database, even other indexed groups, and the files will not be moved in the Finder folders. The script will not move documents from group to group (in the database) nor from folder to folder (in the Finder). If you want to use DEVONthink to move the indexed documents in the Finder, you will need to first move the documents into the database, move them to the indexed groups where they should be moved to in the Finder, then move the documents to the external folder.

So, I have the ‘synchronize’ script attached to quite a few folders to keep the local copies all nice and tidy.

I’d like to be able to add files to DT and have them sync to the folder automatically but if I understand correctly this isn’t possible? I guess what I am interested in is a bidirectional sync of sorts.

It is possible with this script that korm wrote. I use it on several indexed groups and it works well.

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

That’s the script I have attached to these folders. If I drag a file from somewhere else in DT, or from the Finder, it shows up both in DT and the respective new folder location. However, if I delete the file in devonthink it does not remove it from the synced folder.

You have to empty the trash in DEVONthink, and select ‘Files’ or ‘Files & Folders’ to also delete the documents from the synced Finder folder.

That did the trick. Thanks.

Automatic move to external folder script works really well however every single time I enter the folder that uses the script I have to wait until it syncs. It takes several seconds some times to sync and deconsolidate the info with the external folder, especially if the folder contains hundreds of docs. Is there any way to trigger the script manually from the drop-down list of scripts? I could not make it work.