Folder Script - import to specific database/folder

Is there a way to make the folder script that imports/OCR/Deletes files from a watched folder import those files to a specific database and/or folder?

Yes, but… if you are wanting it to go to one specific group you could add that fairly easily. If you want it to detect and sort into several folders, depending on some criteria… that could be much more complicated to do. Not impossible, but the data coming into the script would have to be uniformly occurring to have it behave well consistently.

I have two databases that are usually opened. The one I would like the files to go into is called “personal” I don’t really care what folder in that database it goes into, just the inbox would be fine.

Easy enough. This is a simple change but not error-trapped to see if the database is open.

Change

set theRecord to ocr file thePath to incoming group

to


set theRecord to ocr file thePath to incoming group of database "personal"

I hope that gives you a start. Cheers!

Hi,
I’ve lost the script for giving a folder action of “import and delete” (I can’t find the disk image and the script is empty…) Can you give me the script so I can copy it and apply it to a folder action?

would also like the import, OCR & delete script.

(It would be nice if you have a spot in support with all the scripts with brief description of use for others that can’t find a script)

thanks,
Scott

It’s not included in the Scripts. They are installed in the DEVONthink menu item > Install Add-Ons…

Hi Jim

The current “DEVONthink-Import.scpt” is a folder action which imports newly added files in a folder into the global inbox (“tell application id “DNtp” to import thePath to incoming group”).

If I want to modify the script to import newly added files to a specific group in a specific database, can you advise how may I do it?

Thank you very much
George

There is more than one answer to this.

You can refer to a group by its location in a given database. For example…


set destinationGroup to get record at "/myGroup/mySubGroup" in database "Research"

You can also refer to a group by the alphanumeric string in its reference URL (what you get when you use Copy Item Link). For example…


set destinationGroup to get record with uuid "59F1732E-F0C2-40D9-8688-40E307CD2AF9" 

You would use this variable - here, destinationGroup - instead of incoming group.

Thank you very much!

Dear Jim
Somehow the script editor won’t let me compile the script and shows “Syntax Error”.
Thanks again for the help.

on adding folder items to this_folder after receiving added_items
	try
		if (count of added_items) is greater than 0 then
			tell application id "DNtp" to launch
			set destinationGroup to get record with uuid "4950BE3C-BC07-49E2-"
			repeat with theItem in added_items
				try
					set thePath to theItem as text
					if thePath does not end with ".download:" and thePath does not end with ".crdownload:" then
						tell application id "DNtp" to import thePath to destinationGroup of database "MyDTDatabase"
					end if
				end try
			end repeat
		end if
	end try
end adding folder items to
[quote]

[/quote]

tell application id "DNtp" to launch
         set destinationGroup to get record with uuid "4950BE3C-BC07-49E2-"

This will not work as the first line essentially tells DEVONthink to do something then stops talking to it. When it gets to the second line, you are not talking to DEVONthink so the system has no idea what a record or uuid is. Those words only make sense to DEVONthink.

You could change it to…

tell application id "DNtp"
set destinationGroup to get record with uuid "4950BE3C-BC07-49E2-"
end tell

…or…


tell application id "DNtp" to  set destinationGroup to get record with uuid "4950BE3C-BC07-49E2-"

PS: That doesn’t look like a complete uuid.

Dear Jim

The folder action works now! And indeed I have pasted an incomplete link in the script.

Thanks you very much for your help.
George

No problem. :smiley:

I’m afraid this is a luddite question but … I really want to make this change to the mail rule in Apple Mail so that it moves messages to a specific folder rather than just to the inbox, but this stuff above is greek to me … I can’t figure out where I would make the changes to the rule, or how to do that. Can someone post very basic step by step instructions for how to do this?

Control-click the desired group in DEVONthink and choose Copy Item Link.

Change this line near the top of the script…

set theGroup to get record with uuid <insert the quoted value here>

e.g., set theGroup to (get record with uuid "x-devonthink-item://DE735A62-3C4D-4FFD-ADF5-470857C21D3F")

That should be all that’s necessary but bear in mind the imports will only go to that specific group.