Discussion:
DIR of folders
(too old to reply)
Tom Del Rosso
2023-01-02 08:33:59 UTC
Permalink
One annoying habit of windows is that it doesn't always distinguish
between
DIR C:\WORK
and
DIR C:\WORK\*.*

So if you want to list all folders of a certain name like TEMP
C:\Tech\Android\TEMP
C:\Tech\TEMP

then
DIR /S/B/AD C:\Tech\TEMP

will look only into
C:\Tech\TEMP

and since it doesn't contain another TEMP under it like
C:\Tech\TEMP\TEMP

the output is blank.

I can think of kludgey ways to get around that, but is there an elegant
way?
--
Defund the Thought Police
R.Wieser
2023-01-02 10:03:15 UTC
Permalink
Post by Tom Del Rosso
DIR /S/B/AD C:\Tech\TEMP
will look only into C:\Tech\TEMP
Yes. What you didn't tell is that that folder path actually exists. And in
that case it uses the whole path as the start from which to show all of its
subfolders - instead of searching for that particular folder, starting from
its parent

If the last part of the path doesn't exists it uses the parent as the
starting point and wil look for that folder.

And yes, that means that you can't look for subfolders with the same name as
the one you are starting with. Sorry. (at least, I don't know of any
setting.)
Post by Tom Del Rosso
and since it doesn't contain another TEMP under it like
C:\Tech\TEMP\TEMP
the output is blank.
Not quite. It tries to show you all the subfolders of "C:\Tech\TEMP". And
as there do not seem to be any it (ofcourse) returns nothing.
Post by Tom Del Rosso
I can think of kludgey ways to get around that, but is there an elegant
way?
That fully depends on your definition of both "cludgy" and "elegant". :-)

But yes, I there is. "for /d %%a in (%1\*) do" will iterate thru all
subfolders of the one provided (in %1). You can than compare the result (in
%%a) with whatever you want. A bit of recursion (to search subfolders too)
than does the rest.

Regards,
Rudy Wieser
Herbert Kleebauer
2023-01-02 11:26:11 UTC
Permalink
Post by Tom Del Rosso
One annoying habit of windows is that it doesn't always distinguish
between
DIR C:\WORK
and
DIR C:\WORK\*.*
So if you want to list all folders of a certain name like TEMP
C:\Tech\Android\TEMP
C:\Tech\TEMP
then
DIR /S/B/AD C:\Tech\TEMP
will look only into
C:\Tech\TEMP
and since it doesn't contain another TEMP under it like
C:\Tech\TEMP\TEMP
the output is blank.
DIR /S/B/AD C:\Tech\TEMP*
DIR /S/B/AD C:\Tech\TEMP?
Zaidy036
2023-01-02 15:11:50 UTC
Permalink
Post by Tom Del Rosso
One annoying habit of windows is that it doesn't always distinguish
between
DIR C:\WORK
and
DIR C:\WORK\*.*
So if you want to list all folders of a certain name like TEMP
C:\Tech\Android\TEMP
C:\Tech\TEMP
then
DIR /S/B/AD C:\Tech\TEMP
will look only into
C:\Tech\TEMP
and since it doesn't contain another TEMP under it like
C:\Tech\TEMP\TEMP
the output is blank.
I can think of kludgey ways to get around that, but is there an elegant
way?
XCOPY /T copies only directory structure so can use its output to
control batch flow

Loading...