repeat loop not exiting

Happy New Year!

I have a script that I wrote today, it accomplishes what I need… it moves folders out of the PROOF area if there is not a JOB that corresponds with it.

My problem is that it doesn’t seem to exit the second loop… any ideas why?
the first loop is to get the folder names down to the first 6 characters…
then the second loop compares the proof folder names to the job numbers and moves the proof folder it not found.

doesn’t “repeat with v in myProofFolder” just cycle through once? Or do I need a counter that makes the loop exit?


tell application "Finder"
	set myWorkFolder to name of every folder of folder "  Work Files" in disk "Art Department" whose name does not start with " "
	set myProofFolder to name of every folder of disk "Central PDF Proofs"
	set myDestination to folder "OldProofs0" of disk "Central PDF Proofs" as string
	set M to {}
	set myWorkNumbers to {}
	repeat with k in myWorkFolder
		set tempNum to characters 1 thru 6 of k as string
		set myWorkNumbers's end to tempNum
	end repeat
	repeat with v in myProofFolder
		if v is not in myWorkNumbers then
			set myResult to "False"
			move folder v of disk "Central PDF Proofs" to myDestination
			set myResult to "True"
		end if
	end repeat
end tell

“if v is not in myWorkNumbers then”

should be “if contents of v is not in myWorkNumbers then”

v is a reference to the contents of v that is not dereferenced by the boolean operation.

Also, you’ve defined ‘myDestination’ as a string. You should either leave off the ‘as string’ in the line where it’s defined, or put ‘folder’ in front of it where you use it in the repeat.