Folder actions not working after upgrade to Catalina (DT2)

Hi I have a folder action setup to import, scan/OCR and delete a file when placed into a particular folder. This worked flawlessly until I upgraded to Catalina last night. Now it doesn’t seem to pick up the fact that anything was dropped in the folder. No action is taken. This is a slightly modified version of the import/scan/delete script included with DT Pro.

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"
			set theGroup to get record with uuid "E3BACE3F-A9F4-42A1-8D62-187EDEC11280"
		end tell
		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
					set lastFileSize to 0
					set currentFileSize to 1
					repeat while lastFileSize ≠ currentFileSize
						delay 0.5
						set lastFileSize to currentFileSize
						set currentFileSize to size of (info for theItem)
					end repeat
					
					tell application id "DNtp"
						set theRecord to ocr file thePath to theGroup
						if exists theRecord then tell application "Finder" to delete theItem
					end tell
				end if
			end try
		end repeat
	end if
end try
end adding folder items to

I’m not sure whether the Catalina update has any impact on these settings but did you check that folder actions are still enabled and the action is still attached to the folder?

If you already use DEVONthink 3, then smart rules are a good alternative to folder actions.

Yes I did check… it is still enabled. This is for DT2, not on DT3 – thanks.

Should I submit a support ticket?

47%20AM

You’re running DEVONthink 2 on Catalina?
Do you also have DEVONthink 3 on the same account on that machine?

That’s correct, and no – I have not installed DT3 yet.

It’s something with the below line:

set theRecord to ocr file thePath to theGroup

If I put a “display dialog” before this I can see it, but not after this line. The script seems to crash with this. I can replace this line with “import thePath” and that seems to be fine, but something is not working with ocr. Any suggestions on how I can further debug this? I’ve verified through dialogs displaying vars that thePath and theGroup are both set correctly.

I receive this error when trying to do a Import Image (OCR) from within DT:

59%20AM

I’ve started a support ticket and will update this when I have a solution.

As noted in your support ticket, OCR in DEVONthink Pro Office will not work in macOS 10.15 Catalina. It is a 32-bit process and cannot be run on the new operating system.

This was discussed on our blog here:

you can use ocrmypdf (OCRmyPDF) to ocr the files at the command line and the just use the “Import and Delete” script.

here an example script which looks for files in

/Users/slavisalukic/DMS/scan-ocr

ocrs and copies to

/Users/slavisalukic/DMS/scan-out

you set the folder action to import to DevonThink

the script:

set -e
PATH=$PATH:/usr/local/bin
ST="ocr"
DMS="/Users/slavisalukic/DMS"
SIF=$DMS"/scan-"$ST
SOT=$DMS"/scan-out"
SOC=$DMS"/scan-ocr"
LCK=$DMS/"lock"/$ST"-lock.txt"
LOG=$DMS/"lock"/$ST"-log.txt"
PDFTK="/usr/local/bin/pdftk"
OCRMYPDF="/usr/local/bin/ocrmypdf"

if [ -f $LCK ]
then
    if [ `expr $(date +%s) - $(stat -f %m $LCK)` -lt 300 ]
    then
        echo $ST " locked"
        exit
    fi
fi

echo "lock" > $LCK

if [ -f "$SOC/doc_data.txt" ]
then
    rm $SOC/doc_data.txt
fi

while true
do
	FI=`ls -tc $SOC/ | head -1`
	sleep 1	

	if [ -f "$SOC/$FI" ]
	then
		$OCRMYPDF -l eng+deu+slk $SOC/$FI  $SOT/$FI  >> $LOG 2>&1 && rm "$SOC/$FI" 
	else
		break
	fi
 done

 rm $LCK

et al:
Don’t forget to check out installation instructions, etc. This will not work on a standard Mac without extra effort.