-2

I have one folder XYZ. In XYZ I have multiple folders and Files.

D:/XYZ/Myfolder1/a1.csv D:/XYZ/Myfolder2/ D:/XYZ/Myfolder3/ D:/XYZ/aaa.csv D:/XYZ/bbb.sql

I want to delete folders and every content of that from XYZ Like Myfolder1,Myfolder2,Myfolder3 but not aaa.csv and bbb.sql

How can I write batch for this.

Jack
  • 510
  • 3
  • 6
  • 22
  • Related answer: [Deleting Folder Contents but not the folder](http://stackoverflow.com/a/38769816) (simply remove the `del` command from that solution)... – aschipfl Sep 23 '16 at 08:55
  • not related answer ...Not working in my case ...you have to read question first which is very small – Jack Sep 23 '16 at 09:58
  • You need to replace `C:\Epson Scans` with `D:\XYZ` in the linked answer. By the way, use *backslashes* in paths! forward-slashes are not standard in Windows and might cause trouble with some commands! – aschipfl Sep 23 '16 at 10:01

1 Answers1

1
CD c:\windows
For /f "delims=" %A in ('dir c:\windows /b /ad') Do Echo %A [RD %A /s /q deletes the folder %A] 

See For /?, dir /?, rd /?, and cd /?.