delete some folders wildcard question

October 5, 2009 at 06:30:01
Specs: Windows XP

I have a Backup folder called cod5profiles with over 500 folders in it.

Each of the folders should only have 1 folder in it called $$$, contaning data i need to keep, there is also a text file called active.txt and a file called myreg.key in the backup folder too (not in the $$$ folder)

Due to a mistake on my part many of the folders now have copies of the other 300 folders in them.

Could someone help me with a batch file that will clean out the folders, ie remove any folders that are not called $$$ in each backup folder.

All the backup folders have diferent names but end in cod5, eg:


any help would be wonderful

Thank you


See More: delete some folders wildcard question

Report •

October 7, 2009 at 09:33:54
Hi Mac

Run this above the folder cod5profiles
hence "cd cod5profiles".
Change "rd /s /q "%%b" when happy
as this will not ask for confirmation.

@echo off
cd cod5profiles
for /D %%a in (*.*) do (
echo Directory %%a
cd %%a
for /D %%b in (*.*) do (
if not "%%b" EQU "$$$" rd /s "%%b"

Report •

October 9, 2009 at 09:47:47
Thank you so very much. You talented guys are the boys!

That little batch saved me a good hour+

Kindest regards


Report •

Related Solutions

Ask Question