Computing.Net > Forums > Programming > delete some folders wildcard question

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

delete some folders wildcard question

Reply to Message Icon

Name: Wireworld
Date: October 5, 2009 at 06:30:01 Pacific
OS: Windows XP
Subcategory: Batch
Comment:

Hi,

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:

smithacod5
jonesbcod5

any help would be wonderful

Thank you

Mac



Sponsored Link
Ads by Google

Response Number 1
Name: dtech10
Date: October 7, 2009 at 09:33:54 Pacific
Reply:

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"
)
cd..
)
cd..


1

Response Number 2
Name: Wireworld
Date: October 9, 2009 at 09:47:47 Pacific
Reply:

Thank you so very much. You talented guys are the boys!

That little batch saved me a good hour+

Kindest regards

Mac


1

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More






Use following form to reply to current message:

Login or Register to Reply
LoginRegister


Sponsored links

Ads by Google


Results for: delete some folders wildcard question

Bat Delete some folders but not all www.computing.net/answers/programming/bat-delete-some-folders-but-not-all/15984.html

delete some of the selected lines f www.computing.net/answers/programming/delete-some-of-the-selected-lines-f/15336.html

Batch File Help, 'delete all folder www.computing.net/answers/programming/batch-file-help-delete-all-folder/13383.html