CodeSteps

Python, C, C++, C#, PowerShell, Android, Visual C++, Java ...

Windows – DIR command – How to display the files and folders recursively?

We have seen in our previous Article, displaying files and folders using DIR command in Windows Operating System.We can also display the files and folders from the directory, recursively; that means, list out all the files and folders which are in the specified directory and from all of it’s sub-directories.

How to achieve this? DIR command allows the parameters as switches. The switches will starts with a symbol “/”. These directs the DIR command the operation to perform. One of the switch is “/s”; tells to the DIR command to list all files in subdirectories. For example, below command shows all the files and folders which are in the directory “Personal” and all of it’s sub directories.

C:\> dir Personal /s

If the directory Personal has 3 sub-directories; Docs, Music and Photos; the files and folders of each of these sub-directories will be displayed at the command prompt.

  Directory of C:\Personal
  ...
  Directory of C:\Personal\Docs
  ...
  Directory of C:\Personal\Music
  ...
  Directory of C:\Personal\Photos
  ...
     Total Files Listed:
               0 File(s)              0 bytes
              11 Dir(s)  50,149,380,096 bytes free

Observe that, from above results; DIR command shows the list of files from Personal directory and each of it’s sub-directory; finally it shows the the total number of files and directories found, along with the size of the specified folder (including the size of all of it’s sub directories) and the free disk space.

As the results are too many to fit on the screen, the command shows only the latest details from the results. To see the entire results page by page, you need to pass “/p” switch to the above command. That means, by writing above command as below will shows the results page wise; which enables you to see all the results. You need to “Press any key to continue…” to continue to show the next screen full of information.

C:\> dir Personal /s /p

Be on learning path always!

// Malin

Windows – DIR command – How to display the files and folders recursively?

Leave a Reply

Your email address will not be published. Required fields are marked *

Scroll to top