Deleting files then folders

ECEK

Registered User.
Local time
Today, 13:11
Joined
Dec 19, 2012
Messages
717
Just need a spot of guidance:

I want to delete all of the files in the sub folders of a folder then delete all of those sub folders.

Main folder TEST
Sub folders are employee names Joe Bloggs, Eddie Punchclock, Sally Housecoat etc. The relevant files are house in these sub folders.

Code:
Kill "H:\Test\*.*"
RmDir "H:\Test\"

This doesn't work as there are no files in the Test folder, they are all in the sub folders.

I can't specify the sub folders as the names of the sub folders are generated from a central employee database and may/will change.

Is there a way to wildcard the subfolders or am I going about this the wrong way?

thanks people
 
You can wild card if you use the file system object - something like
PHP:
Dim FSO              As Object    
Set FSO = CreateObject("scripting.filesystemobject")

     Rem * Delete files
FSO.deletefile mypath & "\*.*", True
     Rem * Delete subfolders
FSO.deletefolder mypath & "\*.*", True
 
Thanks Minty. Brilliant as always. I shall get my big VBA book out and study your solution.
 
No Problem - You'll probably have to do something with a recordset to loop around the names from your database to create different versions of the MyPath variable for your different user paths.
 

Users who are viewing this thread

Back
Top Bottom