VBS Script To Browse For A Folder And Delete All Files In It

 

This VBS Script will allow you to browse for a directory folder and will delete all of the files in it.

 

VBS Script:

 

Set objShell = CreateObject("Shell.Application")

Set objFolder = objShell.BrowseForFolder (0, "Select The Folder To Enumerate :", (0))

If objFolder Is Nothing Then

Wscript.Quit

Else

Set objFolderItem = objFolder.Self

objPath = objFolderItem.Path

End If

 

Set objFso = CreateObject("Scripting.FileSystemObject")

Set objFolder = objFso.GetFolder(objPath)

For each objFile in objFolder.Files

If objFolder.Files.Count > 0 Then

objFile.Delete True

End If

Next

 

MsgBox "Done"

 

 

 

Published Thursday, March 12, 2009 8:56 AM by dhite
Filed under:

Comments

No Comments