thanks again Yvan!
Sadly your new code gives me the old error
chmod: /private/var/vm/.Trashes: No such file or directory
I tried wrapping the repeat command in a try command, changed volName to item 4 again, my result:
{{“FF_ext_003”, -1.846161564E+9}}
(1) When editing I misplaced the try/end try statements. It’s now corrected.
(2) To test I asked System Events to return the size of my Applications folder and got a negative value so I decided to use an other tool which is BridgePlus by Shane Stanley.
This one returns a more logical result: {totalFileSize:1.06473994557E+11, totalFileAllocatedSize:8.594223104E+10}
Here is the script using it.
(*
Download BridgePlus here: <http://www.macosxautomation.com/applescript/apps/BridgePlus.html>
Install BridgePlus.scptd in "/Library/Script Libraries/"
*)
use theLib : script "BridgePlus"
use scripting additions
tell application "System Events"
set volNames to name of disks whose local volume is true
--> {"SSD 500", "Macintosh HD"}
end tell
set theSizes to {}
set volName to item 1 of volNames
set POSIXPath2Trashes to POSIX path of (volName & ":.Trashes")
set quotedPOSIXPath2Trashes to quoted form of POSIXPath2Trashes
try # MOVED
do shell script "chmod 775 " & quotedPOSIXPath2Trashes # Standard privileges
set theSize to theLib's sizeInfoForFile:POSIXPath2Trashes
set end of theSizes to {volName, totalFileSize of theSize}
do shell script "chmod 333 " & quotedPOSIXPath2Trashes # Write Only privileges
end try # MOVED
set volNames to rest of volNames
repeat with volName in volNames
set volName to contents of volName
set POSIXPath2Trashes to POSIX path of (volName & ":.Trashes")
set quotedPOSIXPath2Trashes to quoted form of POSIXPath2Trashes
try # MOVED
do shell script "chmod 775 " & quotedPOSIXPath2Trashes with administrator privileges # Standard privileges
set theSize to (theLib's sizeInfoForFile:POSIXPath2Trashes)
set end of theSizes to {volName, totalFileSize of theSize}
do shell script "chmod 333 " & quotedPOSIXPath2Trashes with administrator privileges # Write Only privileges
end try # MOVED
end repeat
theSizes
--> {{"SSD 500", 0}, {"Macintosh HD", 6.08037518E+8}}
Yvan KOENIG running High Sierra 10.13.6 in French (VALLAURIS, France) vendredi 3 mai 2019 12:39:09