Continuing the discussion from Handler to Determine IF Text Contains Item in List:
In the above topic we had quite a disucssion about using the deprecated command
I’m finding I can’t trust anytinig in the ASUG about the performance of
In the above topic I showed that
info for and
System Events required about the same amount of time to get a file size. But now, I’d tested both getting the size of a large folder, my users folder which is about 51GB.
info for vs System Events
System Events takes nearly 6X (5.86) longer
I found comparable times when running from Script Debugger 6.0.7 (6A217) on macOS 10.11.6.
I also tried this on my large DropBox account which has thousands of files, and got similar results.
So, in spite of Apple’s warning that
info for will be slow in getting the size of large folder, I have found it is the fastest method I know of.
Do any of you know a faster method?
Here are my test scripts:
info for Script
use AppleScript version "2.5" -- El Capitan (10.11) or later use scripting additions set itemPath to "/Users/jimunderwood" ### CHANGE to your folder, or any LARGE folder set itemSize to size of (get info for itemPath) set itemSizeGB to itemSize / (1024 ^ 3) return itemSizeGB
System Events Script
use AppleScript version "2.5" -- El Capitan (10.11) or later use scripting additions set itemPath to "/Users/jimunderwood" ### CHANGE to Your Users folder, or other large folder set itemAlias to (POSIX file itemPath) as alias --- Get Size in Bytes of ENTIRE Folder --- tell application "System Events" set itemSize to size of itemAlias end tell set itemSizeGB to itemSize / (1024 ^ 3) return itemSizeGB --- System Events --- -->-0.184760604054 GB -->-198194854 bytes --- Finder (from the Info panel) --- -->56.93 GB -->55,636,440,453 bytes --- info for --- -->51.815 GB -->5.5636314471E+10 bytes --- Bash Script du --- -->0.102789670229 GB -->110369568 bytes
System Events is returning a NEGATIVE size for my users folder, and the ~/Documents folder
It returns a proper positive number for all other folders.
Which is the Correct Size ???
Each method returns a different size. Which should we believe?
For complete reference here’s my shell script:
Bash du Script
set cmdStr to "du -s /users/jimunderwood" set itemSizeStr to (do shell script cmdStr) set itemSize to (first word of itemSizeStr) as number set itemSizeGB to itemSize / (1024 ^ 3) return itemSizeGB -->0.102789670229 GB -->110369568 bytes