Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

DIR of folders

47 views
Skip to first unread message

Tom Del Rosso

unread,
Jan 2, 2023, 3:34:03 AM1/2/23
to
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

unread,
Jan 2, 2023, 5:03:23 AM1/2/23
to
"Tom Del Rosso" <fizzbin...@that-google-mail-domain.com> wrote in
message news:tou4tp$1n7k3$1...@dont-email.me...

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

> 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.

> 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

unread,
Jan 2, 2023, 6:26:14 AM1/2/23
to
On 02.01.2023 09:33, Tom Del Rosso wrote:
> 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

unread,
Jan 2, 2023, 10:11:54 AM1/2/23
to
XCOPY /T copies only directory structure so can use its output to
control batch flow
0 new messages