Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!


Click here to return to the 'Display the size of the trash prior to emptying - Major revision to include above requests' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Display the size of the trash prior to emptying - Major revision to include above requests
Authored by: cougar718 on Feb 28, '03 08:40:52PM

on run {}
set thepath to path to trash -- The folder to size up
-- Get the contents of the trash
set thefiles to list folder thepath -- Gets the directory contents of of the folder specified above
set filteredlist to {} -- Holds the files that don't begin with "."
-- Build the list of files
repeat with thefile in thefiles
if (thefile does not start with ".") then
set end of filteredlist to thefile as string
end if
end repeat
set amount to GetSize(thepath) --Get the physcial size of the folder
set filtercount to count of filteredlist --Count of items in filteredlist
set filecount to count of thefiles --Count of items in thefiles
-- Show user the information gathered
display dialog "There is " & amount & " in the trash. Consists of..." & return
& filecount - filtercount & " invisible(s)" & return
& filtercount & " normal(s)" & return & return
& "Total Files : " & filecount & return & return
& "Would you like to empty the trash?" buttons {"No", "Yes"} default button 2
if button returned of result = "Yes" then
tell application "Finder" to empty trash
end if
end run

on GetSize(thepath)
repeat
try
tell application "Finder" to set thesize to ((physical size of thepath) / 1024)
exit repeat
on error
delay 1
end try
end repeat
if (thesize > 1024) then
set thesize to thesize / 1024 as string
set olddelim to AppleScript's text item delimiters
set AppleScript's text item delimiters to "."
set thesize to every text item of thesize
set item 2 of thesize to item 1 of item 2 of thesize
set thesize to thesize as string
set AppleScript's text item delimiters to olddelim
set thesize to thesize & " MB" as string
else
set thesize to (thesize as integer) & " KB" as string
end if
return thesize
end GetSize

---
Rick Bargerhuff alias cougar
Programmer / Developer
Apple Technician / Specialist / Web Designer
Personal Email: cougar718@comcast.net



[ Reply to This | # ]
Display the size of the trash prior to emptying - Major revision to include above requests
Authored by: toddsnc on Mar 01, '03 02:23:47PM

nice!



[ Reply to This | # ]