Solved Batch Script To Delete Subfolder From Multiple Subfolders

October 8, 2017 at 07:07:08
Specs: Windows 10
Hi There! Total beginner here...

I'm hoping to get a batch script to delete a specific subfolder from multiple subfolders in a specific folder. For example: I have a folder in my C Drive named "Test Folder". In that folder, I have 4 subfolders with the titles "Bill" "Sue" "Bob" "Joe". In each of those 4 folders, I have 3 subfolders titled "Test 1" "Test 2" "Test 3". I want to run a batch script to delete the subfolder "Test 2" from each of the 4 subfolders "Bill" "Sue" "Bob" "Joe".

Ultimately, in production, there will be 1000+ subfolders in the "Test Folder" folder, so this is why I'm looking for a script to assist with this.

I'm currently using Windows 10.

Can anyone help?

Thanks so much!

Jenny


See More: Batch Script To Delete Subfolder From Multiple Subfolders

Reply ↓  Report •

#1
October 8, 2017 at 08:43:14
✔ Best Answer
Assuming you're going to drop this batch script into this "Test Folder," you can probably get away with this (untested):
FOR /D %%a IN (*) DO RD /S /Q "%%a\Test 2"

How To Ask Questions The Smart Way


Reply ↓  Report •

#2
October 8, 2017 at 09:01:25
@ Razor2.3

Thank you, so much, for such a quick reply - and for your assistance!

Ok, so...I'm a total newbie here...

The only way that I'm familiar with running batch scripts is by creating a txt document on my desktop, pasting in the script (making any necessary modifications) and then renaming the file as a .bat file. Then double clicking on it to run it.

Can I do that with the script that you provided me with? I tried, but I don't seem to be having much luck...

Thanks again, so much!

Jenny

message edited by JWill


Reply ↓  Report •

#3
October 8, 2017 at 09:15:20
@ Razor2.3

Ah, disregard my last note! I just figured out what you meant...

I saved your script as a .txt file in the Test Folder (exactly as you suggested haha), and it totally worked!!

Thank you, so much, for taking the time to help me out today! I really appreciate it!


Reply ↓  Report •
Related Solutions


Ask Question