Script: Opening added item with Folder Action

Does anyone know, how to open an item (or the group) and bring it to the front immediately after it was added to Devonthink with a Folder Action Script?

Thanks.

This version of the DEVONthink - Import script will do that.

-- DEVONthink - Import.applescript
-- Created by Christian Grunenberg on Tue Dec 03 2002.
-- Copyright (c) 2002-2014. All rights reserved.
-- mod 20150113 to launch and open DEVONthink focused on the document (korm)

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
			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"
							activate
							set theDocument to import thePath to incoming group
							set theOpen to open window for record theDocument
						end tell
					end if
				end try
			end repeat
		end if
	end try
end adding folder items to

The other folder actions can be modified in a similar manner.

Save a compiled version of this script to ~/Library/Scripts/Folder Action Scripts

Works great. Thank you very much!

By the way, i have another problem:

Is it possible to run an attached script automatically, if an item was added to a group in DTPO? (like Folder Action in OS X)

Or is it possible to trigger a specific group using applescript. So i can use “on triggered” to run an attached script.

Thank you for your help!

Attached a compiled, triggered script to a group using Tools > Show Info > Script.

Here’s the structure


on triggered(theRecord)
   try
      tell application id "DNtp"
         <do interesting things>
      end tell
   end try
end triggered