Introduction
This article will have a specific content about how to save the directory structure of a path in Microsoft Windows to a file. Actually, it is very useful to have an overall view of the structure inside a path. For an example, it is useful for locating a certain directory. In term of checking the relation of another directory for a specific requirement in a certain programming language or framework. Basically, a certain programming language or framework will require a certain directory to be exactly precise in a certain location. The reason is because of another file or another directory will use it to be able to run properly.
Save Directory Structure of a Path in Microsoft Windows to a file
Actually, in order to print the directory structure of a path, there is a command or a file for further execution. That command is a file with the name of ‘tree’. The command ‘tree’ is available in the Microsoft Windows operating system. The following is the command pattern for printing a structure of the directory below :
tree /f /a > file_name
There are two additional parameters after the ‘tree’ command. The first one is ‘/f’ and it will print the output in the form of the names of the files found within each directory recursively. Next, the second one is ‘/a’ is where it will print the output which includes alternative characters (plus signs, hyphens, and vertical bars) be used to draw the tree diagram. The main purpose is that it can be printed by printers that don`t support the line-drawing and box-drawing characters, such as DOS Versions 4 and 5.
Furthermore, there is a redirect output after both of the parameters. It will instruct the command to redirect the output of the program not to the output terminal but into another form of output. In this case, it is a file with the name of ‘file_name’. Just choose any file name in order to store the output of the command. Below is a sample of the command pattern execution above :
C:\programming\python\django>tree /f /a > test.txt C:\programming\python\django>
Finally, check the content of the file. Actually, the content exist as follows :
Folder PATH listing for volume Windows Volume serial number is E003-3593 Folder PATH listing for volume Windows Volume serial number is E003-3593 C:programming\python\django. | test.txt +---env ... +---myapp ... +---myproject
In order to shorten the output, not every listed folder and files appeear in a recursive form completely as exist above.