VBScript for delete files

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,
 
G

Gerry Hickman

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.
 
G

Guest

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,
 
G

Gerry Hickman

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top