Exclude certain Files in Folder action script?

I’m working on a way to automate the OCR of PDF files and have been using the Applescript code posted by Joe Kissell in MacWorld http://www.macworld.com/article/60229/2007/10/nov07geekfactor.html

I’ve been using Acrobat, but have decided to move to OCRKit to handle the job.

The issue is that OCRKit appends a “-OCR” string to the end of the filename and the Folder Action script wants to reprocess those files.

I’d like to exclude anything with a “-OCR” in the filename, but haven’t been able to figure out a correct and efficient way to do so.

I’ve looked at numerous ideas here, but those have mostly for search and replace in the filename. I haven’t understood how I can incorporate those into my script.

Here’s my current script, adapted from what was posted in MacWorld:

on adding folder items to this_folder after receiving these_items
		
	repeat with i from 1 to number of items in these_items
		set this_item to item i of these_items
		set the item_info to info for this_item
		set the item_size to size of (info for this_item)
		set delay_time to ((item_size / 1024 / 30) as integer)
		set file_type to name extension of (info for this_item)
	
	-- Need to exclude "-OCR" files from being processed
				
		if file_type is equal to "pdf" then
			
		
			tell application "OCRKit"
				activate
				open this_item
			end tell


		end if
	end repeat
end adding folder items to

I would think i need to modify the If statement to exclude the files, but am not certain that’s a good way to handle the issue.

Thanks for any help you can provide.

Cheers,
Jon

Model: Mac Mini
Browser: Safari 528.16) OmniWeb/v622.11.0
Operating System: Mac OS X (10.4)

An insertion of another if-statement should do the trick

on adding folder items to this_folder after receiving these_items
	
	repeat with i from 1 to number of items in these_items
		set this_item to item i of these_items
		set the item_info to info for this_item
		set the item_size to size of (info for this_item)
		set delay_time to ((item_size / 1024 / 30) as integer)
		set file_type to name extension of (info for this_item)
		
		-- Need to exclude "-OCR" files from being processed
		
		if file_type is equal to "pdf" then if (name of item_info) does not contain "-OCR" then
			
			
			tell application "OCRKit"
				activate
				open this_item
			end tell
			
			
		end if
	end repeat
end adding folder items to

Hope it works,
ief2

That works perfectly.

Thanks for your help.

Cheers,
Jon