How can I export a directory structure in Windows?

Solution 1:

Assuming your directory tree is of reasonable size, you could also use the built in tree command, which produces a rather pretty looking directory tree. Unfortunately this prettiness is difficult to get working outside of a cmd instance, so you'll probably want to tell it to just use ascii characters with the /A switch.

Example:

From a small multi-level structure

+---A
|   +---A
|   \---B
+---B
|   \---A
|       \---A
\---C

You can then redirect this to a file using a command like:

tree /A ["directory path"] > tree.txt

Where the directory path is optional, but useful if you want to tree something which isn't the current working directory.

Solution 2:

If you want to use powershell the code is very simple and the output is nice.

Code:

Get-ChildItem | tree

With

Get-ChildItem | tree > foo.txt

you can pipe the output to a Textfile.

Example Output:

Auflistung der Ordnerpfade für Volume System
Volumeseriennummer : 48E9-F43B
C:.
├───Contacts
├───Desktop
├───Downloads
│   └───Evernote Import
├───Dropbox
│   ├───Apps
│   │   └───iftttcom
│   │       └───getpocketpdf
│   ├───Backup
│   ├───Camera Uploads
│   ├───Development

Solution 3:

You can also put the results directly into the clipboard (in Vista+):

tree | clip

Solution 4:

While you most likely want the output of the TREE command (e.g. TREE /F > output.txt) in this case, if raw text as the output is fine, then you can run the following from a command prompt:

DIR C:\ /S > output.txt

Where output.txt will be generated in the current working directory, and contain a listing of all files and directories on the C: drive. If you want just an output of files with their full paths, run the following:

DIR C:\ /B /S > output.txt

It would also be a trivial task to write a program to parse the output back into a directory view style program for you to view.

Solution 5:

Open command prompt window --> Go to your directory path

Then run the following command to generate

tree /f /a > tree.doc

Above command will make the folder and files structure recursively and export to word document file. You can find "tree.doc" created in the same folder