Link to home
Start Free TrialLog in
Avatar of COV-Webmaster
COV-WebmasterFlag for Canada

asked on

VB Script or Batch File to Delete Files and Folder Except for Two Specified Folders That Should not be Deleted

I'm looking for a VB script or batch file that can delete all files and folders in a nested directory structure except for two specific folders.  An example is:

C:\test\nextlevel\nextlevel\

Delete all files and folders except for:

C::\test\nextlevel\nextlevel\dontdelete1
C::\test\nextlevel\nextlevel\dontdelete2

I would appreciate any advice on how to do this.

Thanks.
Avatar of Bill Prew
Bill Prew

So, for the folders not to be deleted, do you want to specify just the folder name, or the full path to that folder? So in you example, do you want to specify

C:\test\nextlevel\nextlevel\dontdelete1
C:\test\nextlevel\nextlevel\dontdelete2

or just

dontdelete1
dontdelete2

~bp
Avatar of COV-Webmaster

ASKER

I would like to specify the full path to the folders that should not be deleted.

Thanks.
ASKER CERTIFIED SOLUTION
Avatar of Bill Prew
Bill Prew

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thanks very much!  This works exactly the way I need it to.
Great, glad that helped.

~bp