Windows 10: Find number of folders in every sub-folder

  1.    04 Mar 2018 #1

    Find number of folders in every sub-folder


    This is not exactly Windows questions. I wasn't too sure where to post, hence posting here. Admins, feel free to move to appropriate forum.

    Here is the task,
    I have 'C:\Data' folder that contains 1000s of folders. Each Subfolder should ideally contain one child folder in which there are minimum 3 and maximum 6 files. I have noticed that some folders have ended up with more than one child folders. I would like to find out which of these subfolders have more than one subfolder.
    Is there any utility or script that I can run to find out subfolders that contain more than one child subfolder and export it to CSV or something like that?

    I am not aware of exact terminology of these folders so if I am not making any sense, pls comment and will clarify more.

    Many thanks in advance.
      My ComputerSystem Spec

  2.    04 Mar 2018 #2

    Hi, you might be able to use Wiztree or Treesize e.g. - the number of folders is listed in a column
    Top 5 Free Portable Windows Tools to Analyze Folder Structures | Next of Windows
      My ComputerSystem Spec


  3. Posts : 7,643
    10 Home x64 (1803) (10 Pro on 2nd pc)
       04 Mar 2018 #3

    If it helps, you can create a text file with a list of all the folders in C:\Data and their subfolders from the command prompt. Type this command:

    dir C:\Data /a:d /s > %userprofile%\desktop\folderlist.txt

    This will put the directory listing on your desktop in the file 'folderlist.txt'.

    Note that in addition to actual subfolders (if any) every folder will contain the '.' and '..' directories. These are shorthand for the current folder and its parent folder respectively. The /b option will create a more compact list without the '.' and '..' entries, try each and see which is the easier to read/use.

    dir C:\Data /b /a:d /s > %userprofile%\desktop\brief_folderlist.txt
      My ComputersSystem Spec

  4.    04 Mar 2018 #4

    In PowerShell, this will print out the total number of subfolders within each 1st level subfolder of the parent.

    Code:
     Get-ChildItem -Directory | ForEach-Object {$_.name + "," + (Get-ChildItem -Directory  -Recurse $_.FullName|Measure-Obj
    ect).count }
    So for:
    parent\
    parent\child 1\child child 1\
    parent\child 2\
    parent\child 3\
    parent\child 3\child child 3\child child child 3\
    parent\child 3\child child 4\

    Code:
    PS C:\temp> cd parent
    PS C:\temp\parent>PS C:\temp\parent> Get-ChildItem -Directory | ForEach-Object {$_.name + "," + (Get-ChildItem -Directory -Recurse $_.Full
    Name|Measure-Object).count }
    child 1,1
    child 2,0
    child 3,3
    PS C:\temp\parent>
      My ComputerSystem Spec


 

Related Threads
I need to know the number of files, all of them, on C:\ (not the amount of used space). :p
I'm going to take my laptop and make it our spare. Before I do that I want to wipe it and do a fresh install for several reasons. I know I'll need my activation key in order to reactivate windows, but I upgraded this pc from W8.1 to W10 and have no...
General Tips Find Serial Number of Windows PC in Tutorials
How to Find Serial Number of Windows PC Sometimes abbreviated as Serial No., SN or S/N, a serial number is a unique number assigned to the PC by the OEM (Original Equipment Manufacturer) used for identification and inventory purposes. A serial...
General Tips Find Windows 10 Version Number in Tutorials
How to Find Windows 10 Version Number This tutorial will show you how to find and see what the version number of the installed Windows 10 is on your PC. Windows 10 version history and Windows 10 release information Version
I'm having some issues with my antivirus software. Support sent the following request: I looked at ipconfig and the router user guide but don't know how to find my VPN license or the "order number". How do I find my VPN license?
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 08:50.
Find Us