Lazy loaded image
如何用Tree列出資料夾結構包含子資料夾及檔案
Words 252Read Time≈ 1 min
2024-9-23
2025-3-11
1
 
因為工作的需要,往往要列出目前資料夾的結構,其實在windows的cmd就有很好用的工具。
只要在cmd上輸入 tree /f 就可以顯示資料夾結構,如下所示。

python

D:\temp>tree /f 列出資料夾 PATH 磁碟區序號為 xxxx-xxx D:. ├─新增資料夾 │ │ 新增 Bitmap image - 複製.bmp │ │ 新增 Bitmap image.bmp │ │ │ └─新增資料夾 │ 新增 Text Document - 複製.txt │ 新增 Text Document.txt │ ├─新增資料夾 - 複製 │ 新增 Text Document - 複製 (2).txt │ 新增 Text Document - 複製 (3).txt │ 新增 Text Document - 複製.txt │ 新增 Text Document.txt │ └─新增資料夾 - 複製 (2)
Python
 

語法

bash

tree /f 目錄名稱
Bash
例如

bash

tree /f d: tree /f c:/temp
Bash
 
將結果輸出到檔案

bash

tree /f 目錄名稱 > dirs.txt
Bash

For Linux

Installation

shell

# For Debian-based distributions sudo apt-get install tree # For RPM-based distributions sudo yum install tree # Output: # 'tree' is now installed on your system.
Shell

參考

詳細語法可以參考 tree | Microsoft Learn
上一篇
[python]批次將資料夾內的檔案轉換成UTF-8
下一篇
如何利用Github建立多個個人網站

Comments
Loading...