1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

. and .. directories counted by @files function

Discussion in 'Support' started by mathewsdw, Mar 6, 2011.

  1. mathewsdw

    Joined:
    May 24, 2010
    Messages:
    855
    Likes Received:
    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?
     
  2. Kachupp

    Joined:
    Aug 9, 2009
    Messages:
    133
    Likes Received:
    0
    try this mathewsdw

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


     
  3. Steve Fabian

    Joined:
    May 20, 2008
    Messages:
    3,523
    Likes Received:
    4
    ---- Original Message ----
    From: mathewsdw
    To: ESFabian@zenge.org
    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
     
  4. mathewsdw

    Joined:
    May 24, 2010
    Messages:
    855
    Likes Received:
    0
    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...
     
  5. mathewsdw

    Joined:
    May 24, 2010
    Messages:
    855
    Likes Received:
    0
    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).
     
  6. samintz

    samintz Scott Mintz

    Joined:
    May 20, 2008
    Messages:
    1,177
    Likes Received:
    11
    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:


    "%D",+d]"




    the future?
     

Share This Page