CMD Dir command, how count number of folders?


  1. Posts : 133
    Windows 10 Home 64bit 22H2
       #1

    CMD Dir command, how count number of folders?


    Hi,
    if I use dir command in CMD, it shows 2 dirs even is that dir empty (if is not root directory). So I think "." and ".." is counted as dir too. Is that right? So anytime if I want check number of dirs in any folder (except root folder) I have to deduct 2. Is that correct?
    Thanks.
      My Computer


  2. Posts : 8,125
    windows 10
       #2

    Dir *.* Shows all files dir *.jpg show all jpg files normally you cd\folder then dir *.* You can in explorer right click folder select properties and it will number of file etc
      My Computer


  3. Posts : 18,034
    Win 10 Pro 64-bit v1909 - Build 18363 Custom ISO Install
       #3

    Hello @TheOwner,

    TheOwner said:
    If I use dir command in CMD . . .
    Are you talking about something like this [ obviously change Your Path to your actual path ] ?

    Copy & Paste the following command[s] [ ALL at once ] into a CMD Prompt and press Enter.

    Code:
    
    @echo off
    set "Folder_Path=Your Path"
    PowerShell "Get-ChildItem '%Folder_Path%' -Recurse -Directory | Measure-Object | ForEach-Object{$_.Count}"

    I hope this helps.
      My Computer


  4. Posts : 17,012
    Windows 10 Home x64 Version 22H2 Build 19045.4170
       #4

    TheOwner said:
    if I use dir command in CMD, it shows 2 dirs even is that dir empty (if is not root directory). So I think "." and ".." is counted as dir too. ... So anytime if I want check number of dirs in any folder (except root folder) I have to deduct 2. Is that correct?
    Yes.

    TheOwner said:
    So I think "." and ".." is counted as dir too. Is that right?
    I've never seen any explanation of what . and .. are.


    Denis
      My Computer


  5. Posts : 821
    Windows 7
       #5

    Try3 said:
    I've never seen any explanation of what . and .. are.
    They're borrowed from UNIX.

    "." is shorthand for current directory, ".." is for the parent directory.

    .\setup.exe -> run setup.exe from current folder, instead of allowing the PATH variable to run a different setup.exe that it finds while searching the PATH.

    cd .. -> Jump up one folder level. If you're already at the \ folder, ".." points back to the root folder.
      My Computer


  6. Posts : 17,012
    Windows 10 Home x64 Version 22H2 Build 19045.4170
       #6

    The OP asked what those things were in the response to a Dir cmd.
    Your post is about how to use notation in commands. That is not the same issue.
    I've never seen an explanation of what they actually are when returned by a Dir cmd [and displayed in some third-party equivalents of File explorer].


    All the best,
    Denis
    Last edited by Try3; 02 Apr 2023 at 13:36.
      My Computer


  7. Posts : 43,185
    Win 10 Pro (22H2) (2nd PC is 22H2)
       #7

    Hi, have a look at this which covers Windows, Powershell and command prompt (DIR):

    4-ways-count-number-folders-and-files-inside-folder
      My Computers


 

  Related Discussions
Our Sites
Site Links
About Us
Windows 10 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 10" and related materials are trademarks of Microsoft Corp.

© Designer Media Ltd
All times are GMT -5. The time now is 12:01.
Find Us




Windows 10 Forums