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

浪子不回头ぞ 提交于 2019-12-03 00:02:48

问题


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.


回答1:


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.




回答2:


If you want to list folders and files like graphical directory tree, you should use tree command.

tree /f

There are various options for display format or ordering.

Check example output.

Answering late. Hope it help someone.




回答3:


An addition to the answer: when you do not want to list the folders, only the files in the subfoldes, use /A-D switch like this:

dir ..\myfolder /b /s /A-D /o:gn>list.txt



回答4:


An alternative to the above commands that is a little more bulletproof.

It can list all files irrespective of permissions or path length.

robocopy "C:\YourFolderPath" "C:\NULL" /E /L /NJH /NJS /FP /NS /NC /B /XJ

I have a slight issue with the use of C:\NULL which I have written about in my blog

https://theitronin.com/bulletproofdirectorylisting/

But nevertheless it's the most robust command I know.




回答5:


If you simply need to get the basic snapshot of the files + folders. Follow these baby steps:

  • Press Windows + R
  • Press Enter
  • Type cmd
  • Press Enter
  • Type dir
  • Press Enter


来源:https://stackoverflow.com/questions/15214486/command-to-list-all-files-in-a-folder-as-well-as-sub-folders-in-windows

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!