Mittwoch, 29. Dezember 2010

Delete specific files

This script was developed to delete files with a specific extension inside a given folder. In this case, installation logs from MS Patch / Hotfix Installations will be deleted. This script can easily be adopted to delete other files also.

DIM fso, f, fc, file
Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fso.GetFolder("c:\winxp")
Set fc = f.Files
For Each file in fc
  if strcomp(right(file.name,4),".log",1)=0 then
    fso.DeleteFile("c:\winxp\" & file.name)
  end if
Next

Keine Kommentare:

Kommentar veröffentlichen