error handler to continue with repeat

Hi,

So say I have a repeat loop with actions for a list of files:

set theFiles to {“file1.txt”,“file2.txt”,“file3.txt”}
repeat with theItem in theFiles
→ I run each file in the list through some sort of process
end repeat

The problem is, if an error is encountered with ONE of the files, it stops the ENTIRE repeat loop and stops all the error free files from being processed. How can I add an error handler so that if an error is encountered, to just keep moving along with the other files?

Hi,

no offense, but some of your questions are very basic, so I recommend to read some of the great AppleScript for Beginners tutorials at unscripted
For example: AppleScript for Beginners VII - Errors

Add just a try block


set theFiles to {"file1.txt", "file2.txt", "file3.txt"}
repeat with theItem in theFiles
	try -- if an error occurs, everything will be skipped until the end try line
		-- do something
	end try
end repeat