getting file size of a specific file

please help with syntax. i’m trying to edit this script to run with a specific file,
and i’m getting an error: File Alaska:Desktop:EH:test.gif wasn’t found.


	
set fileSize to 0
set latestCheck to 1

repeat until fileSize is equal to latestCheck
	tell application "Finder" to set fileSize to info for "Alaska:Users:sl:Desktop:EH:test.gif"
	do shell script "sleep 2"
	--set latestCheck to size of (info for the_filename)
	--if fileSize is equal to latestCheck then
	--else
		--do shell script "sleep 10"
	--end if
end repeat


I would also love to know what is an item? what is a property? when must i declare a path as alias?

select the item and then run this amking sure the result is “Alaska:Users:sl:Desktop:EH:test.gif”
if not change your script

tell application "Finder"
	return ((item 1 of (get selection)) as alias) as text
end tell

Try this, soda:

	set fileSize to size of (info for file "Alaska:Users:sl:Desktop:EH:test.gif")
	delay 2

…or this:

	tell application "Finder" to set fileSize to size of file "Alaska:Users:sl:Desktop:EH:test.gif"
	delay 2

Thanks for your suggestions.

this works


set the_filepath to "Alaska:Users:sl:Desktop:EH:" & the_image --where the_image is test.gif
	tell application "Finder" to set fileSize to size of (info for file the_filepath)

Yes, it will work, soda - but I’m afraid that you’ve missed the point of my suggestions. Perhaps I should have been more explicit (but it was way past my bedtime when I replied)…

There are several ways in which you can determine the size (or other property) of a file. You could use an application that can access the required property (such as Finder or System Events). Alternatively, you could use ‘info for’, from the File Commands Suite of the Standard Additions scripting addition.

I find ‘info for’ generally faster than the other methods, which are nevertheless perfectly valid. However, there seems little point in using both a Finder tell and the info for command. This just makes your statement unnecessarily verbose and (on average in tests here) takes about 3 times as long to execute as ‘info for’ does on its own.