close

如何產生網路上常見的目錄樹狀結構?

 

在網路上常見如下範例一結構,這稱為‌「目錄樹狀結構」。

 

範例一

└── yolov7
    ├── datasets
    │   └── VisDrone
    │       ├── train
    │       │   ├── images
    │       │   ├── labels
    │       │   └── labels.cache
    │       └── val
    │           ├── images
    │           ├── labels
    │           └── labels.cache
    └── yolov7-master

 

接著就來介紹如何產生「目錄樹狀結構」。

1. 開啟 Windows PowerShellCommand Prompt 命令視窗。

 

2. 先輸入 tree /? 來查看有哪些參數可設置。

PS D:\> tree /?
Graphically displays the folder structure of a drive or path.

TREE [drive:][path] [/F] [/A]

   /F   Display the names of the files in each folder.
   /A   Use ASCII instead of extended characters.

PS D:\>

 

訊息寫著

Graphically displays the folder structure of a drive or path.

以圖形方式顯示驅動器或路徑的資料夾結構。

 

/F   Display the names of the files in each folder.

/F 顯示每個文件夾中文件的名稱。

 

/A   Use ASCII instead of extended characters.

使用 ASCII 而不是擴充字元。

 

3. 輸入以下命令即可產生整個「目錄樹狀結構」。

PS D:\> tree /F 'D:/New folder' > 'D:/MyTree.txt'

 

命令說明

  • tree 是用來產生「目錄樹狀結構」的命令。
  • /F 顯示每個文件夾中文件的名稱。
  • 'D:/New folder' 目錄開始產生「目錄樹狀結構」。
  • > 是將產生的「目錄樹狀結構」導出到指定的路徑,並儲存成 .txt 檔案。
  • 將「目錄樹狀結構」導出儲存成指定的路徑和檔案名 'D:/MyTree.txt'。
arrow
arrow
    文章標籤
    [Tree] [PowerShell] [DOS]
    全站熱搜

    mitblog 發表在 痞客邦 留言(0) 人氣()