Archived from groups: microsoft.public.win2000.setup_deployment (More info?)
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.
Enric wrote:
> 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,
Archived from groups: microsoft.public.win2000.setup_deployment (More info?)
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?
> 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.
>
> Enric wrote:
>
> > 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,
>
>
> --
> Gerry Hickman (London UK)
>
Archived from groups: microsoft.public.win2000.setup_deployment (More info?)
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.
> 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,
>
> "Gerry Hickman" wrote:
>
>
>>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.
>>
>>Enric wrote:
>>
>>
>>>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,
>>
>>
>>--
>>Gerry Hickman (London UK)
>>
'Delete specified folder and subfolders
'Atention!!! Files or folders will not be saved in Recycle Bin
strFolderPath="C:\New Folder"
Set fso=CreateObject("Scripting.FileSystemObject" )
If fso.FolderExists(strFolderPath) Then
set demofolder = fso.GetFolder(strFolderPath)
'The True parameter remove the folder forcefully
fso.DeleteFolder strFolderPath, True 'Delete the copied folder
'fso.CreateFolder strFolderPath 'Create a new folder with the name specified in variable
'fso.DeleteFolder(strFolderPath) 'Another method for delete
WScript.Echo "Deleted folder!!!"
else
WScript.Echo "Inexistent folder!!!"
End If
You are about to answer a thread that has been inactive for more than 6 months. If you still wish to proceed, please ensure that your posting is original and does not duplicate or overlap any prior responses to this thread.