Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Delete folder

Status
Not open for further replies.

giahan

Programmer
Sep 1, 2000
139
US
Hi,

I am trying to delete folders and their subfolder on my server using ASP.
My foldernames are test41214, test41216, test3231,....
Is there anyway that I can delete all folders containing "4121" which means all of the folders test41214, test41216 are deleted.
Any help will be appreciated
Thanks
GH
 
Risky but.
Code:
DeleteFolders "C:\Myfolders"
Sub DeleteFolderList(folderspec)
    Dim fs as scripting.FileSystemObject
    Dim f as scripting.Folder
    Dim fc as scripting.Folders
    Dim f1 as scripting.Folder

    Set fs = CreateObject("Scripting.FileSystemObject")
    Set f = fs.GetFolder(folderspec)
    Set fc = f.SubFolders
    For Each f1 in fc
        If Instr(1,f1.name,"4121")> 0 then
            fs.DeleteFolder(f1.Path,True) ' force
        end if
    Next
End Sub

 
What you mean by "risky"?
Thanks


GH
 
FileSystemObject itself is not risky.
The risk is YOU (and me) and the user you give the application to. I'm scared shirtless about deleting folders/files in an application. This goes back to the bad old "DEL *.*" days of DOS.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top