VBScript for delete files

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

dear gurus,

I would need a vbscript which delete all the files of a set of folders.

Does anyone know how could i do such thing?
regards,
 
Hi,

There's two options, you can either delete the folder at the top of the
tree (thereby deleting everything below it), or you can delete specific
files. The WSH object is called the FileSystemObject and can be used
with VBSciprt and JScript.
 
Thanks Gerry,

But I was wondering how can I do a loop in the top folder (foldergeneral) in
order to check out every folder and once there, delete the specified files?

\\folder1\foldergeneral\1
\\folder1\foldergeneral\2
\\folder1\foldergeneral\3
\\folder1\foldergeneral\4

Best regards,
 
Hi Enric,

Well you wanted one thing, and now you want something different -
enumeration of folders and testing of files before deletion. In general
this is done using recursion with the SubFolders collection of the
Folder object of the FileSystemObject, or you can use WMI if you don't
care about UNC paths.

For full details and examples, you may want to post about this in the
WSH newsgroup on this server.

If you want advanced programming examples, you may want to post in the
WMI newsgroup on this server.
 
Back
Top