Find number of folders in every sub-folder


  1. Posts : 63
    Wiindows 7 going to 10
       #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 Computer


  2. Posts : 42,998
    Win 10 Pro (22H2) (2nd PC is 22H2)
       #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 Computers


  3. Posts : 31,674
    10 Home x64 (22H2) (10 Pro on 2nd pc)
       #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 Computers


  4. Posts : 809
    Win10
       #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 Computer


 

  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 18:05.
Find Us




Windows 10 Forums