Rob van der Woude's Scripting Pages
Powered by GeSHi

Source code for deltrash2.kix

(view source code of deltrash2.kix as plain text)

  1. ; DelTrash2.kix,  Version 1.00
  2. ; Empty the Recycle Bin, or remove only files older than the specified number of days
  3. ; 
  4. ; Usage:  KIX32  DELTRASH2.KIX  [ /A:days ]  [ /Q ]
  5. ; 
  6. ; Where:  days   is the minimum age in full calendar days of files to be deleted
  7. ;                (0 means delete everything older than today)
  8. ;         /Q     suppresses screen output (number of items and MBs)
  9. ; 
  10. ; Notes:  [1]    This script requires BinManager by Tim Tabor
  11. ;                http://www.cheztabor.com/BinManager/
  12. ;         [2]    This script was based on Tim Tabor's own JScript sample
  13. ; 
  14. ; Written by Rob van der Woude
  15. ; http://www.robvanderwoude.com
  16.  
  17.  
  18. $rc = SetOption( "Explicit", "ON" )
  19.  
  20. Dim $arrAge[1], $arrArgs[], $blnQuiet, $intAge, $intItems, $intSize, $objBin, $strArg, $strMsg
  21.  
  22. ; Get BinManager object
  23. $objBin = CreateObject( "BinManager.RecycleBin" )
  24.  
  25. $intItems = $objBin.NumItems
  26. $intSize  = $objBin.Size
  27. $arrArgs  = GetCommandLine(1)
  28. $blnQuiet = 0
  29. $intAge   = -1
  30.  
  31. For Each $strArg In $arrArgs
  32. 	If UCase( $strArg ) = "/Q"
  33. 		$blnQuiet = 1
  34. 	EndIf
  35. 	If InStr( UCase( $strArg ), "/A:" )
  36. 		$arrAge = Split( $strArg, ":" )
  37. 		$intAge = CInt( $arrAge[1] )
  38. 	EndIf
  39. Next
  40.  
  41. If $intAge = -1
  42. 	$rc = $objBin.Empty( )
  43. Else
  44. 	$rc = $objBin.DeleteOldItems( $intAge )
  45. EndIf
  46.  
  47.  
  48. If $blnQuiet = 0
  49. 	? $intItems - $objBin.NumItems
  50. 	" items were removed from the Recycle Bin ("
  51. 	FormatNumber( ( ( $intSize - $objBin.Size ) / 1048576 ), 1, -1, 0, 0 )
  52. 	" MB)@CRLF"
  53. 	$intSize = FormatNumber( ( $objBin.Size / 1048576 ), 1, -1, 0, 0 )
  54. 	"The Recycle Bin still holds " + $objBin.NumItems
  55. 	" items (" + $intSize + " MB)@CRLF"
  56. EndIf
  57.  
  58. Exit
  59.  

page last uploaded: 2017-08-21, 14:26