0

I need a batch file to traverse a directory structure that looks like this

C:\CruiseControl\ProjectArtifacts\ProjectName1\Logs C:\CruiseControl\ProjectArtifacts\ProjectName1\Src C:\CruiseControl\ProjectArtifacts\ProjectName1\Data C:\CruiseControl\ProjectArtifacts\ProjectName2\Logs C:\CruiseControl\ProjectArtifacts\ProjectName2\Src C:\CruiseControl\ProjectArtifacts\ProjectName2\Data C:\CruiseControl\ProjectArtifacts\ProjectName3\Logs C:\CruiseControl\ProjectArtifacts\ProjectName3\Src C:\CruiseControl\ProjectArtifacts\ProjectName3\Data

And so on...

The project name is always unique and there can be up to 100 variations on the ProjectName folder.

I want to delete the Src folder and all files/folders contained within it for each project. The Logs and Data folders should NOT BE deleted in this process. How can I go about doing this?

let me know if you need more info.

1

No batch file needed:

for /d %P in ("c:\CruiseControl\ProjectArtifacts\*") do @rd /s /q "%P\src" 2>nul

If you want a batch file, then change all %P to %%P

  • What if {Logs, Src, Data} aren't the only 3 directories? – Kruug Aug 21 '13 at 21:11
  • @Kruug - There could be any number of arbitrarily complex folders under each project, but the code above will only delete the ..\src folders (and all files and folders under it) from each project. The code does assume that all projects are at the same level of the directory tree, as was implied by the OP. – dbenham Aug 21 '13 at 22:13
  • I was way overcomplicating things :) thanks for the help! – Richie086 Aug 21 '13 at 23:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.