Dir is an command used to list all directories and files of a folder

It will not list out all subdirectories

Syntax

dir options

dir command without options list out all folders of a current directory.

B:\parent>dir
 Volume in drive B has no label.
 Volume Serial Number is 0A9B-F96C

 Directory of B:\parent

01-09-2021  14:43    <DIR>          .
01-09-2021  14:43    <DIR>          directory1
01-09-2021  14:42    <DIR>          directory2
01-09-2021  14:43    <DIR>          directory3
               0 File(s)              0 bytes
               4 Dir(s)  72,082,702,336 bytes free

Recursive directory listing

/s option with dir command elements list out all file and folder names and sub folder of a current direcoty.

B:\parent>dir /s
 Volume in drive B has no label.
 Volume Serial Number is 0A9B-F96C

 Directory of B:\parent

01-09-2021  14:43    <DIR>          .
01-09-2021  14:43    <DIR>          directory1
01-09-2021  14:42    <DIR>          directory2
01-09-2021  14:43    <DIR>          directory3
               0 File(s)              0 bytes

 Directory of B:\parent\directory1

01-09-2021  14:43    <DIR>          .
01-09-2021  14:43    <DIR>          ..
01-09-2021  14:43    <DIR>          directory1-1
01-09-2021  14:43    <DIR>          directory1-2
               0 File(s)              0 bytes

 Directory of B:\parent\directory1\directory1-1

01-09-2021  14:43    <DIR>          .
01-09-2021  14:43    <DIR>          ..
               0 File(s)              0 bytes

 Directory of B:\parent\directory1\directory1-2

01-09-2021  14:43    <DIR>          .
01-09-2021  14:43    <DIR>          ..
               0 File(s)              0 bytes

 Directory of B:\parent\directory2

01-09-2021  14:42    <DIR>          .
01-09-2021  14:43    <DIR>          ..
               0 File(s)              0 bytes

 Directory of B:\parent\directory3

01-09-2021  14:43    <DIR>          .
01-09-2021  14:43    <DIR>          ..
01-09-2021  14:43    <DIR>          directory3-1
01-09-2021  14:43    <DIR>          directory3-2
               0 File(s)              0 bytes

The above command gives header and footer information.

List files and directoris and sub folders recursively

This is another way of printing files and subfolder information

B:\parent>dir /b /s
B:\parent\directory1
B:\parent\directory2
B:\parent\directory3
B:\parent\directory1\directory1-1
B:\parent\directory1\directory1-2
B:\parent\directory3\directory3-1
B:\parent\directory3\directory3-2

if you want file names in sorted order, You can use sortorder option as described below

dir /s /b sortorder:N