Search code examples
windowscommand-linecommanddir

Command to list all files in a folder as well as sub-folders in windows


I tried searching for a command that could list all the file in a directory as well as subfolders using a command prompt command. I have read the help for "dir" command but coudn't find what I was looking for. Please help me what command could get this.


Solution

  • The below post gives the solution for your scenario.

    dir /s /b /o:gn
    

    /S Displays files in specified directory and all subdirectories.

    /B Uses bare format (no heading information or summary).

    /O List by files in sorted order.

    Then in :gn, g sorts by folders and then files, and n puts those files in alphabetical order.