Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!

. and .. directories counted by @files function

May
855
0
I simply want to count the number of subdirectories that exist below a particular directory in a directory tree. "%@Files[/S "%D",+d]" almost works except that it also counts the dot and double-dot directories in the tree, and I can't, as far as I can tell, compensate for them using the @Eval function (if it can be done that way, the math is too complicated for me to figure out right now!). Is there any way to do this, or Rex could you please add this capability to the @Files function (similar to the /H operand on the dir command and the default for the pdir command) at some point in the future?
 
try this mathewsdw

dir /b /a:+d | (echo %@lines[con])


> -----Original Message-----
> From: mathewsdw [mailto:]
> Sent: Monday, 7 March 2011 12:41 a.m.
> Subject: [Support-t-2652] . and .. directories counted by @files
> function
>
>
> I simply want to count the number of subdirectories that exist below
> a particular directory in a directory tree. "%@Files[/S "%D",+d]"
> *almost* works except that it *also* counts the dot and double-dot
> directories in the tree, and I can't, as far as I can tell,
> compensate for them using the @Eval function (if it can be done that
> way, the math is too complicated for me to figure out right now!). Is
> there any way to do this, or Rex could you please add this capability
> to the @Files function (similar to the /H operand on the dir command
> and the default for the pdir command) at some point in the future?
>
 
---- Original Message ----
From: mathewsdw
To: [email protected]
Sent: Sunday, 2011. March 6. 06:41
Subject: [Support-t-2652] . and .. directories counted by @files
function

| I simply want to count the number of subdirectories that exist below
| a particular directory in a directory tree. "%@Files[/S "%D",+d]"
| almost works except that it also counts the dot and double-dot
| directories in the tree, and I can't, as far as I can tell,
| compensate for them using the @Eval function (if it can be done that
| way, the math is too complicated for me to figure out right now!). Is
| there any way to do this, or Rex could you please add this capability
| to the @Files function (similar to the /H operand on the dir command
| and the default for the pdir command) at some point in the future?

Try "%@Files[/S "%D",d]" - this variant invocation on my system always returns the same count as the directory count in the command, and manually verified not to include the . and .. directories:

*dir/s/a:d/u2/h
--
HTH, Steve
 
---- Original Message ----
From: mathewsdw
To: [email protected]
Sent: Sunday, 2011. March 6. 06:41
Subject: [Support-t-2652] . and .. directories counted by @files
function

Try "%@Files[/S "%D",d]" - this variant invocation on my system always returns the same count as the directory count in the command, and manually verified not to include the . and .. directories:

*dir/s/a:d/u2/h
--
HTH, Steve
Steve,

Thank you, but that is exactly what I was doing so it was a real mystery to me until I thought about it some more. The problem turned out to be that there were a number of "hidden" directories in the directory tree that @Files was counting and I had completely forgotten about. I may be getting older but that doesn't mean I'm getting wiser...
 
try this mathewsdw

dir /b /a:+d | (echo %@lines[con])

Thank you sir. That's a really unusual (but clever!) way to do it. But it turns out I didn't need it because I figured out why I wasn't getting the answer I expected from the "@Files" function (my mistake, of course).
 
After some experimentation I found that
I get different results depending on whether /S is specified or not. It
seems that when /S is *not* specified the dot directories get counted.
But if it *is* specified they do not get counted.

Also /S0 counts the dot directories,
but /S1 does not.

-Scott

mathewsdw <> wrote on 03/06/2011
06:41:17 AM:


> mathewsdw <>
> 03/06/2011 06:41 AM
>
> Please respond to
>
>
> To
>
> [email protected]
>
> cc
>
> Subject
>
> [Support-t-2652] . and .. directories counted by @files function
>
> I simply want to count the number of subdirectories that exist below
> a particular directory in a directory tree. "%@Files[/S
"%D",+d]"

> *almost* works except that it *also* counts the dot and double-dot


> directories in the tree, and I can't, as far as I can tell,
> compensate for them using the @Eval function (if it can be done that
> way, the math is too complicated for me to figure out right now!).


> Is there any way to do this, or Rex could you please add this
> capability to the @Files function (similar to the /H operand on the


> dir command and the default for the pdir command) at some point in
the future?
 

Similar threads

Back
Top