Multiple loop criteria

I am trying to get a loop to run through a list of items, testing each item and then I want the loop to finish either when the loop runs out of items or if the internal test proves true.

I assume there are 2 ways I could do this… but I don’t know how to do either in Apple script.

The following art my bastardized solutions that obviously don’t work because I don’t know the correct syntax. Can somebody help me solve them?

The following uses multiple loop criteria to maintain the loop. If the test comes back as true it will terminate the loop


tell application "Finder"
	set workingFolder to choose folder
	set folderItemList to items of workingFolder as alias list
	set textMatch to false
	repeat with currentFolderItem in folderItemList or until textMatch is true
		if kind of currentFolderItem is "Folder" then
			try
				find text "^[a-zA-Z]{2}_\\d+" in (displayed name of currentFolderItem) as string with regexp
				set textMatch to true
			end try
		end if
	end repeat
end tell

The following uses some sort of loop terminator… I dont know if Applescript has this sort of function


tell application "Finder"
	set workingFolder to choose folder
	set folderItemList to items of workingFolder as alias list
	repeat with currentFolderItem in folderItemList
		if kind of currentFolderItem is "Folder" then
			try
				find text "^[a-zA-Z]{2}_\\d+" in (displayed name of currentFolderItem) as string with regexp
				terminate repeat
			end try
		end if
	end repeat
end tell

You don’t say “terminate repeat”, you say “exit repeat”.