troubleshooting Question

Help to write a script

Avatar of ethar1
ethar1Flag for Saudi Arabia asked on
VB Script
4 Comments1 Solution278 ViewsLast Modified:
Dear all,
Need a help to complate the following script to delete all files in a specific folder and subfolders if specific cretiria are met ( file name is "xxxx.yyy" and file size <= 1kb)
also to print out on command windows the deleted files with its full path
'' /// Setup environment declarations and object references ///
Dim objFSO:Set objFSO = CreateObject("Scripting.FileSystemObject")
Dim objShell:Set objShell = CreateObject("Wscript.Shell")
Dim objFolder:Set objFolder = objFSO.GetFolder("D:\webspace")

' /// Run the main routine, ProcessFolder, a recursive search through the files/folders found in the objFolder reference ///
  ProcessFolder (objFolder)

' /// Destroy object references, finalizing the script ///
Set objFolder=Nothing
Set objShell=Nothing
Set objFSO=Nothing

' /// Main routine to scan current folder and recursively call against sub folders ///
Sub ProcessFolder(fld)
  Set subFld = objFSO.GetFolder(fld) ' Set object reference against current folder
  ProcessFile (subFld) 'Call Processfile routine against current folder
  For Each fld In subFld.SubFolders 'loop through all subfolders, recalling the same routine
    ProcessFolder (fld) 
End Sub

' /// Routine to process all container files within the passed folder reference
Sub ProcessFile(fld)

  Set objFld = objFSO.GetFolder(fld) 'create object reference to the current folder
  For Each file In objFld.Files 'loop through all files found
  If objFSO.GetExtensionName(file) = "php" Then 


    Set objFile = Nothing 'destory object reference
  End If

End Sub
Join our community to see this answer!
Unlock 1 Answer and 4 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 4 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros