when # of items equal another folders items end repeat

I am trying to make a repeat loop stop when the amount of items of one folder equal the amount of items in another folder. (in this case x)

x in the bottom script was defined earlier in my larger script as:

tell application "Finder"
	set theList to files of folder "Illustrations:Users:admin:Desktop:PDF_Franchise_Calls:Files_With_Dot:"
	set x to number of items in theList
end tell

I can’t seem to make the below script work. Can anyone explain why?

tell application "Finder"
	set OutFolder to alias "Illustrations:Users:admin:Desktop:PDF_Franchise_Calls:Out:"
	set upload_folder to alias "Illustrations:Users:admin:Desktop:PDF:"
	set wait to true
	repeat while wait is true
		repeat 10 times
			try
				duplicate entire contents of OutFolder to folder "Illustrations:Users:admin:Desktop:PDF" with replacing
				
				duplicate entire contents of OutFolder to folder "Illustrations:Users:admin:Desktop:PDF_Franchise_Calls:Backup_PDF_Files" with replacing
				
			end try
			set folderCheck to list folder upload_folder without invisibles
			if folderCheck = {} then
				--display dialog "still repeating"
				delay 3
			else if folderCheck = x then
				set wait to false
				display dialog "Your PDF has been created. Check inside the folder on your desktop called 'PDF'." buttons {"OK"} default button 1
				return
			end if
		end repeat
	end repeat
end tell

Hi Jeff,

you’re trying to compare a list (folderCheck) with an integer (x)

...
set folderCheck to count (list folder upload_folder without invisibles)
			if folderCheck = 0 then
				--display dialog "still repeating"
				delay 3
			else if folderCheck = x then
				set wait to false
...

this line will never be true

else if folderCheck = x then

try changing it to

else if (count of items of folderCheck) = x then

::edit:: dang it Stefan beat me to the punch

That’s was it!!!
That was tearing up for quite some time. Than you so much for your response.

-Jeff