NSReceiverEvaluationScriptError: 3

I have three scripts that use the following code to process images. One works, the other two I get this error, telling me that the variable

these_files

is not set. Logging the error I get this message “NSReceiverEvaluationScriptError: 3”.
Applescript is up to date. I do not get the error on a differant machine of the same setup. If I just rebuild the script or make a new script I get the same error. The other script is identical but the startup folder is differant.
I do not understand what is happening.

set this_folder to (choose folder with prompt "Pick the folder containing the images to process:") as string
tell application "System Events"
	set these_files to every file of folder this_folder whose name does not start with "." and (file type is "TIFF" or file type is "JPEG" or name extension is "tiff" or name extension is "tif" or name extension is "jpeg" or name extension is "jpg")
end tell
repeat with i from 1 to the count of these_files
	set this_file to (item i of these_files as alias)
	
end repeat

Brandon,

The code works fine on my machine - 10.3.4. If it works fine on other boxes, you might want to try restarting, repairing permissions, etc… I’ve run into problems with scripts/programs that permission repair solve.

Further testing shows that even after repairing the permissions, which did not repair anything, the error still occurs. Further, sometimes the “System Events” will return an empty list, even if there are files that should show in the list. The culprit is the .DS_Store which is hidden in the folder.
I have a cron job that runs and cleans up the folder, deleting .DS_Store and ._* hidden files that cause some Windows and Java applications to fail when run. After deleting the .DS_Store and the other hidden files the script will either fail, reporting that the variable “these_files” is not defined (NSReceiverEvaluationScriptError: 3 in the log) or a empty list is returned even after moving files into the folder.
I am able to recreate the error every time the .DS_Store is deleted and the idle part of the script runs. The part that is erroring is within the idle handler.

I would very much appreciate others seeing if they can recreate this error.

To delete the .DS_Store without invisibles items set to visible in Finder, from the command line:
find /pathto/folder/ -name .DS_Store -exec rm -f -v {} ;

Applescript to run:

on run
	set this_folder to (choose folder with prompt "Pick the folder containing the images to process:") as string
	tell me to idle
end run

on idle
	tell application "System Events"
		set these_files to every file of folder this_folder whose name does not start with "." and (file type is "TIFF" or file type is "JPEG" or name extension is "tiff" or name extension is "tif" or name extension is "jpeg" or name extension is "jpg")
	end tell
	repeat with i from 1 to the count of these_files
		set this_file to (item i of these_files as alias)
		
	end repeat
end idle

Thanks for any ideas and help
Brandon

couldnt you use a without invisibles after the “set these_files”

Hi,

You need to declare the variable this_folder as global:

global this_folder

otherwise it will be local in the idle handler.

gl,