I’m currently facing the problem that I have to do an operation in every first dir “layer” of a directory.
I have a folder with thousands of sub dirs, I would just dor a for loop with /r but the problem is, those sub-dirs contain more sub-dirs an I don’t want to go into those.
For visualization:
Root Dir
----Sub-Dir 1
--------Sub-Dir 1 of Sub-Dir 1
--------Sub-Dir 2 of Sub-Dir 1
----Sub-Dir 2
--------Sub-Dir 1 of Sub-Dir 2
--------Sub-Dir 2 of Sub-Dir 2
----Sub-Dir 3
--------Sub-Dir 1 of Sub-Dir 3
--------Sub-Dir 2 of Sub-Dir 3
and I only want to go into the first “layer” Sub-Dir 1,2,3 etc. and don’t touch the sub-sub-dirs of each.
All you need are nested FOR /D statements (total of 2).
EDIT
Here is a generic solution that allows you to specify the root folder as arg1 (%1) and how many levels down to go as arg2 (%2).