Converting Images to file size

Hi,
i have just stupid question - I am trying to convert and resize folder of images to (or less) then given size. But I have problem by given size of files from Finder - it does not returns the changed file size, it returns still the same size. Please does anyone has answer for me. Look at the code (using the GraphicConverter)

tell application “GraphicConverter”
activate
repeat with i from 1 to loopFinish
set currentFile to item i of fileList
set the tempFile to the name of currentFile
tell application “Finder”
set datS to size of item i of fileList as integer
end tell
open currentFile as alias

	set picDim to image dimension of window tempFile
	set picHor to item 1 of picDim
	set picVert to item 2 of picDim
	if picHor > picVert then
		set newVert to round ((hor / picHor) * picVert)
		set newHor to hor
	else
		set newVert to hor
		set newHor to round ((hor / picVert) * picHor)
	end if
	
	set image dimension of window tempFile to {newHor, newVert}
	set qual to 100
	
	if datS > 10000 then
		repeat with y from 1 to 50
			set JPEG quality of window tempFile to qual
			set qual to qual - y
			save window tempFile as JPEG with wwwready
			set datS1 to data size of file in window tempFile
			tell application "Finder"
				set datS to size of file tempFile in folder pathName
				set datS to datS as integer
			end tell				
		end repeat
	end if
	close window tempFile
end repeat

end tell

Sounds like a classic Finder caching problem.

For performance reasons, the Finder caches a lot of information. It’s likely that the Finder caches the data the first time you get the file size.

When you come to check it again a few seconds later, the Finder returns the value from the cache rather than rechecking the file. 99% of the time this would be correct, but you’ve hit the 1%.

The solution is to use the Finder’s ‘update’ command to force it to refresh the information about this file, like:

...
tell application "Finder" 
update file tempFile in folder pathName
set datS to size of file tempFile in folder pathName 
...