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


Click here to return to the 'Automatically empty the trash when items are trashed' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Automatically empty the trash when items are trashed
Authored by: Brennan on Aug 06, '03 08:38:14PM
What about getting the Trash to suggest that it be empted when it contains more than x MB
property oneMB : 1000000
property maxSize : oneMB * 10

on adding folder items to thisFolder after receiving theseFiles
 
 try
  set thisFolder to choose folder
  set fldrPath to (thisFolder as string)
  set itemz to (list folder thisFolder)
  
  set collectedSize to 0
  repeat with i in itemz
   set thisFile to (fldrPath & i) as string
   set fileinfo to info for thisFile
   set collectedSize to collectedSize + (size of fileinfo) -- bytes!
  end repeat
  
  if collectedSize > maxSize then
   set MBs to (collectedSize / oneMB) as string
   set str to "The trash contains " & MBs & "MB. " & return
   set str to str & "Empty it?"
   set dr to (display dialog str)
   set br to dr's button returned
   if br is "OK" then
    tell application "Finder" to empty
   end if
  end if
  
 on error msg number n
  display dialog "Script error: " & msg
 end try
 
end adding folder items to


[ Reply to This | # ]