0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

【bat・PowerShell】起点とするフォルダの配下フォルダのみをtree構造で出力する

Last updated at Posted at 2025-01-17

はじめに

起点としたいフォルダ配下のフォルダ構成をtree構造で表現したかったのですが、
ググってもうまく答えにたどり着けなかったので記録として残します。

結論

treeコマンドに起点としたいフォルダのパスを指定します。
treeコマンドはPowerShell,bat双方で使用可能です。

tree 起点とするフォルダのパス

今回の例

今回の例として、C直下に「おためしフォルダ」を作成し、
その配下にいくつかのフォルダを作成しました。

image.png

実行結果

無事に「おためしフォルダ」を起点としたtree構造が出力されました。
画像を載せていないですが、PowerShellでも同じコマンドで同様の出力が可能です。

image.png

C:\おためしフォルダ>tree C:\おためしフォルダ
フォルダー パスの一覧:  ボリューム Windows
ボリューム シリアル番号は 7E1C-134A です
C:\おためしフォルダ
├─chinpan
├─gorira
└─saru

備考

パスとして共有フォルダを指定する場合、エイリアスでも実行可能でした。
(指定しない場合どえらい量が出力されて使い物にならないので注意)

おわりに

今回の私と同じようにtree構造にしたいけどやり方がわからなかった誰かに届けば幸いです。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?