Getting size of folders

Hey guys,

I am new and learning applescript. Can anyone help me with this script. I am simply trying to list the size of the folders.

Seems very simple, but I can’t figure out what I am doing wrong.

Please advise.

set folderSelected to choose folder "Select a folder"

tell application "Finder"
	set listOfFolders to every folder of folderSelected
end tell

set theList to {}
repeat with aFolder in listOfFolders
	set theSize to size of aFolder
	set theList to theList & theSize
end repeat

Browser: Safari 536.28.10
Operating System: Mac OS X (10.8)

Hi,


set folderSelected to choose folder "Select a folder"

tell application "Finder"
	set listOfFolders to every folder of folderSelected
	set theList to {}
	repeat with aFolder in listOfFolders
		set theSize to size of aFolder
		set end of theList to theSize
	end repeat
end tell
return theList

Is this what you were trying to do?

gl,

Thanks but I get the following result:

{missing value, missing value, missing value, missing value}

I am trying to get the sizes (in bytes) of those 4 folders, listed in the result field.

I was wondering why I had missing value on some list items. Maybe it’s packages?

You get missing value when the Finder is still calculating the size.
Use a repeat loop to wait until the value is not missing value

Correct, but not all folders are actually calculated. There is an possibility the script will wait forever, so an timeout using maximum attempts should be added as well.