[Office efficiency improvement] Window10 and ubuntu recursively list the files and folders in the current directory and all subdirectories

In the Windows operating system, there is no built-in functionality similar to Ubuntu's "tree" command. However, you can use the following two methods to achieve similar functionality:

Method 1: Using the dir command and recursion
You can use the Windows built-in command "dir" and the recursive parameter "/s" to list the directory structure. Open a command prompt (or PowerShell) and navigate to the folder where you want to view the directory structure. Then enter the following command:

dir /s

This will recursively list the files and folders in the current directory and all its subdirectories.

Use case: ` dir 'D:\adobe acrobat X pro\ROOT'

insert image description here
`Case analysis record: dir 'D:\adobe acrobat X pro\ROOT' >> log.txt

Method 2: Use the Tree command line tool
You can download the third-party command line tool "Tree", which provides functions similar to Ubuntu's "tree" command in Windows. You can use the Tree command line tool as follows: tree /f
After executing this command, it will display all subdirectories and files in a tree structure under the current directory. Each directory will be preceded by a "+" sign and the filename will be represented by a folder icon.

insert image description here

On Windows, the tree command can be used to display a hierarchy of directories and files in a tree structure. However, the Windows command prompt (cmd) does not have a built-in tree command, but there are some other ways to achieve similar functionality.

One way is to use the dir /s /b command, which lists the paths of all files and folders in the current directory and all subdirectories. This will be displayed in a flat form rather than a tree structure.

To use the dir /s /b command, please open a command prompt window, then switch to the directory you want to view, and finally enter the dir /s /b command and press the Enter key.

For example, if you want to view the files and folders in the D:\s directory and all its subdirectories, you can perform the following steps:

Open the command prompt window: In Windows, press the Win + R keys, type "cmd" and press the Enter key to open the command prompt window.

Change to the target directory: Use the cd command to switch to the D:\s directory. For example, type cd D:\s and press Enter.

Execute the dir /s /b command: Enter the dir /s /b command and press Enter. The command recursively lists the paths of all files and folders in the D:\s directory and all its subdirectories.

Similarly, you can also use tree to export files and all file subdirectories at once:

tree /f >> log.txt

insert image description here

Guess you like

Origin blog.csdn.net/weixin_41194129/article/details/131099091