On windows, there’s a tree command to display the directory structure of a path or of the disk in a drive graphically. For convenience, I wrote a right-click menu. Whenever I need to get the directory information of a folder, I just need to right-click on the folder and select Get Tree Here to generate a .ctre file in the current directory. The .ctre file contains the output of the tree command.


This code snippet is also available in my gist.

First, I created a batch file named gettree.bat

REM file: gettree.bat
@tree "%~1" /F /A | more /E /S +2 > "%~1\%~nx1.ctre"

Then, I added this batch file to the right-click menu through registry.

Windows Registry Editor Version 5.00

@="Get Tree Here"

@="X:\\Command\\gettree \"%V\""

@="Get Tree Here"

@="X:\\Command\\gettree \"%1\""

Change X:\\Command\\gettree to the path of gettree.bat. Save the above code as gettree_reg.reg, double-click this file, and the menu item of Get Tree Here will be added to the right-click menu.


After the above steps, right-click the folder or drive and a Get Tree Here option will appear.

Create windows directory structure file using tree command on right content menu

The following is the execution result in a test directory.

|   input.ctre
|       config.js
|       jax.js
|   |   config.js
|   |   jax.js
|   |   
|   \---entities
|           a.js
|           b.js
|           c.js
|           d.js
|           e.js
|           f.js
|           fr.js
|           g.js
|           h.js
|           i.js
|           j.js
|           k.js
|           l.js
|           m.js
|           n.js
|           o.js
|           opf.js
|           p.js
|           q.js
|           r.js
|           s.js
|           scr.js
|           t.js
|           u.js
|           v.js
|           w.js
|           x.js
|           y.js
|           z.js


Leave a Reply

Your email address will not be published.