# Deleting all folders excluding few folders and files

Hi ,

i want to delete all folders inside a path excluding few folders. Also it should not delete files which resides inside that path

Example:

I have C:\DATA folder, inside it i have 5 folders named aaa , bbb, ccc, ddd , eee . and there are two files one.txt and two.txt inside C:\DATA folder. Now i want to delete all folders inside C:\DATA except ccc and ddd folders and also i dont want to delete the files under C:\DATA

Remove-Item -Force -recurse -Path C:\Data* -exclude ‘ccc’, ‘ddd’

i tried with above command, but it is deleting files also C:\DATA folder, i can not give . in exclusion as i have few folders with name like aaa.bbb inside C:\DATA. I mean, i do not want to give the file names in exclusion list as the C:\DATA may contain large number of files.

How about using `-Exclude *.*,"ccc","ddd"`, try the same without using `*` in path.