folder sizes

I need to get the size of a folder. The path for this is stored in the string variable selSrcFolder.

I have tried this:

set sourceSize to size of folder (selSrcFolder)

I have also tired:

set sourceSize to size of (info for alias (selSrcFolder))

I have also converted the path to a POSIX path.

I get an error telling me that the file doesn’t exist, but I know that it does.

any suggestions?

Hi Dee,

paths in AppleScript are always colon separated HFS paths (only in do shell script arguments POSIX paths are required)
The first example works only within a Finder or System Events tell block,
but can take some time if the folder has many subfolders, so use a repeat block to wait

set selSrcFolder to path to library folder as Unicode text
tell application "Finder"
	repeat until size of folder selSrcFolder is not missing value
		delay 1
	end repeat
	set sourceSize to size of folder selSrcFolder
end tell

the second example works (with a HFS path), but can also return missing value, if the time to calculate the size is too long

Thanks, the delay helps not return a nul value, but I still had a problem with my path. If I substitute “path to documents folder” it all worked. So I used “POSIX file (selSourceFolder) as Unicode text” and that worked.