You are herescripting

scripting


Linux: Find large files

Finds all files over 20,000KB (roughly 20MB) in size and presents their names and size in a human readable format:

find / -type f -size +20000k -exec ls -lh {} \; | awk '{ print $9 ": " $5 }' 

VBScript: Delete files older than x days

The example below simply deletes any files older than 2 days from the root of the F:\Files directory.

  1. Dim Fso
  2. Dim Directory
  3. Dim Modified
  4. Dim Files
  5.  
  6. Set Fso = CreateObject("Scripting.FileSystemObject")
  7. Set Directory = Fso.GetFolder("F:\Files")
  8. Set Files = Directory.Files
  9.  
  10. For Each Modified in Files
  11.  
  12. If DateDiff("D", Modified.DateLastModified, Now) > 2 Then Modified.Delete
  13.  
  14. Next

The FOR Command

The FOR command is one of those commands that can save you hours of repetitive work. As a sysadmin its important to look for easy ways to get rid of repetitive tasks like renaming files or copying a select number of files. I recently had to retrieve 3,000+ files from a folder containing over 3,000,000 files. Imagine how long it would take to selectively find these files. The benefit of the FOR command is that it is a "looping" command. In other words, it will do a given task over and over until a given condition is met.