Script to Import, OCR & Delete-with selectable destination

I edited (slightly) the excellent script/Folder Action that comes with the new DTPO, intended to import, OCR and delete files.

I added the option to select the destination group.

I am a relative AppleScript beginner, so I am sure some of you mavens might clean up my simple efforts, but at least I believe this creates a folder action where I can drop files from my finder, and have all actions completed in one fell swoop.

Cheers!

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 "com.devon-technologies.thinkpro2" to launch
			tell application id "com.devon-technologies.thinkpro2"
				set theGroup to display group selector "Select the destination group"
				repeat with theItem in added_items
					try
						set thePath to theItem as text
						if thePath does not end with ".download:" then
							tell application id "com.devon-technologies.thinkpro2"
								set theRecord to ocr file thePath to incoming group
								tell application "Finder"
									set filename to name of theItem
									if text -4 of filename is "." then
										set Nm to (text 1 through -5 of filename)
									end if
									
									
								end tell
								
								if exists theRecord then tell application "Finder" to delete theItem
								tell application id "com.devon-technologies.thinkpro2"
									set name of theRecord to Nm
								end tell
							end tell
						end if
					end try
				end repeat
			end tell
		end if
	end try
end adding folder items to

this is wonderful, sawxray! thanks.

just out of curiosity, do you think it would be possible to select a unique destination that remains permanent for a particular finder folder?

:slight_smile:

Hermes-

You are most kind. I am an AppleScript noobie, and only working off of others’ efforts.

I personally don’t know how to set up a specific Finder folder to automatically send to a DTP folder, but must say that is an excellent idea! One could take the most common DTP destinations, and create a single Finder folder for each, which would make importing much easier.

Hopefully one of the mavens here can help.

Cheers!

Is it possible to make this into an application or something other than a folder action?

Folder actions is not working on my machine and I don’t know why. I’ve tried the Apple forums but that is another story.

Since I can’t use folder actions I’m using launchbar and I am trying to send a file to launchbar and then open the file with this script. I tried saving it as an application and it still doesn’t work.

I used your code but deleted two different lines regarding adding files to a folder.

tell application id "com.devon-technologies.thinkpro2" to launch
tell application id "com.devon-technologies.thinkpro2"
	set theGroup to display group selector "Select the destination group"
	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 "com.devon-technologies.thinkpro2"
				set theRecord to import thePath to theGroup
				
				if exists theRecord then tell application "Finder" to delete theItem
			end tell
		end if
	end try
end tell

What do you think?

Hello!

Great script. Is there a way tommodify the script, so my workflow is possible?

  1. The scanned paper drops in a folder
  2. a folder action copies the doc into dtpo
  3. OCR starts
  4. the doc in the finder folder wil be moved to an archive folder on a external hdd