How to Export Folder Structure to Excel on Windows PC or Mac

Sometimes you may need to share the structure of a particular directory with others. There is no need to manually rewrite the name and hierarchy of each folder and file. Instead, you can quickly export it to a preferred format and import it into Excel. Then the program will automatically organize the data into neat rows and columns. This guide explains how to export an entire folder structure to an Excel file. Plus, it answers…

Sometimes you may need to share the structure of a particular directory with others. There is no need to manually rewrite the name and hierarchy of each folder and file. Instead, you can quickly export it to a preferred format and import it into Excel. Then the program will automatically organize the data into neat rows and columns.

This guide explains how to export an entire folder structure to an Excel file. Plus, it answers the most common questions related to export Excel files.

How to Export Folder Structure to Excel on Windows

To export a folder structure to Excel in “.doc” format, you must first create an “output.doc” file containing the folder structure. Follow the instructions below:

  • Open your file explorer and find the necessary folder.
  • Click on the File Explorer address bar and type “cmd” to open a command prompt.
  • Press the “Enter” key.
  • Type the command “tree /a /f > output.doc” in the command prompt window and press the “Enter” key.
  • Wait for the command to finish executing and close the command prompt window.
  • Go back to your file explorer and open the folder you want to export.
  • You will see a text file called “output.doc”, containing the entire folder structure.

Note: you can save the “output.doc” file in “.txt” format if necessary and give it a different name.

Now that you have the folder structure in “.doc” format, you can import it into Excel:

  • Open a new or existing Excel file and navigate to the “Data” tab.
  • Click on “From text”.
  • Select your “.doc” file in the File Explorer window, then click “Import”.
  • In the Text Import Wizard window, select the “Delimited” option in the first step of the dialog box and click “Next”.
  • Select the necessary delimiters in the second step of the dialog box and click “Next”. In the case of the “.doc” format, the delimiter is a tabulation.
  • Specify the desired data format in the third step of the dialog box, then click “Finish”.
  • Select “Existing Spreadsheet” and enter “=$A$1” in the field below to make sure the data starts in cell Row1, Column A. You can also select another cell.
  • Click “OK” to complete the data export.

How to Export Folder Structure to Excel on Windows as “.CSV” File

If you need to save the folder structure in “.csv” format rather than “.doc”, you can do so using Windows PowerShell:

  • Use the keyboard shortcut “Windows + X” to open a quick access menu.
  • Select “Windows PowerShell” from the menu.
  • Paste the following command into the PowerShell window and press the “Enter” key: “Get-ChildItem -Recurse ‘d:demo’ | Select-Object FullName, name | Export-Csv -path d:list.csv -noTypeInfo”. Replace “d:demo” with the name of your folder.
  • Wait for PowerShell to generate a file in “.csv” format containing the folder structure.

Once you have the file, follow the steps below to import it into Excel:

  • Launch Excel and open a new or existing spreadsheet.
  • Go to the “Data” tab.
  • Click on “From text”.
  • Select the “.csv” file containing your folder structure and click on “Import”.
  • In the first step of the Text Import Wizard window, select the “Delimited” option and click “Next”.
  • Choose the delimiter in the second step and click “Next”. In the case of the “.csv” file format, it is a comma.
  • Select the preferred data format in the third step and click “Finish”.
  • Click on “Existing Spreadsheet” and select the spreadsheet cell to put your data.
  • Click “OK” to complete the export.

How to Export Folder Structure to Excel Directly

If you have Excel 2016 or newer, you may not need to export the folder structure to a separate file before importing it into Excel. Instead, try the direct export method shown below:

  • Launch Excel and open a new or existing spreadsheet.
  • Go to the “Data” tab at the top of the window.
  • Click on “Get Data” to open a drop-down menu.
  • Select “From File”, then “From Folder”.
  • Browse File Explorer for the needed folder. When you find it, select it and click “OK”.

Note: Sometimes you may not be able to click “OK” when choosing the parent folder. In this case, select a sub-folder and click on the name of the address at the bottom of the window. Next, delete the subfolder name at the end of the line, leaving only the parent folder name, and click “OK.”

That’s it – all the contents of the folder will automatically be organized into columns and rows. You can also export only specific subfolders to Excel using this method instead of the entire folder structure.

How to Export Folder Structure to Excel on a Mac

Mac users can export folder structure to Excel as easily as Windows users. However, the instructions are slightly different:

  • Open the necessary folder and use the keyboard shortcuts “Command + A”, then “Command + C”.
  • Launch the TextEdit application on your Mac and click “Edit”.
  • Select “Paste and Match Style” from the drop-down menu.
  • Click on “File”, then on “Save” and save the file in “.txt” format in the location of your choice.

Once you have the file containing the folder structure, follow these steps to import it into Excel:

  • Open an Excel spreadsheet.
  • Click “Data” at the top, then click “From Text.”
  • Select the necessary “.txt” file and click on “Import”.
  • In the first step of the Text Import Wizard window, select “Delimited” and click “Next”.
  • Select “Tab” as the delimiter, then click “Next”.
  • Select “Existing Spreadsheet” and choose the spreadsheet cell to put your data. For example, if you choose “=$A$1”, your data will be organized starting with the cell in row 1, column A.
  • Click “OK” to complete the data export.

FAQs

Read this section to learn more about exporting a folder structure to Excel.

What is a delimiter and why do I need it?

When exporting a folder structure to Excel, you need to select the correct delimiters in the Text Import Wizard window. The delimiter refers to a character that separates strings of data, indicating a program where one piece of data ends and the next begins. In other words, the program interprets it as the end of the field rather than part of the text. For example, if the delimiter is “/”, a program reading “john/doe” will interpret it as “john doe”. Delimiters are needed to export different file formats to Excel and other programs with correct formatting.

What is the difference between “.doc” and “.csv” file formats?

You can export folder structure to Excel in different formats and you might be wondering which one is better. Both are text formats that save line breaks, tab characteristics, characters, and other formatting elements of the exported sheet. The difference is in the delimiter – “.doc” and “.txt” formats are tab delimited, while “.csv” is comma-delimited.

For example, the text “john doe” in “.doc” format will appear as “john doe”, while in “.csv” format as “john,doe”. There is either a tab or a comma between each field. In most cases, you can export data in any format because Excel supports both. But if the data is not exporting correctly in one of them, you can try the other one to fix the problem.

Can I export only the folder structure without files in “.doc” format?

When you export the structure of a folder in “.doc” or “.txt” format using the command “tree /a /f > output.doc” via the command prompt, you get a file containing the entire contents of the folder, including files. If you don’t need to export the files but only the folders, use the “tree /a > output.doc” command instead.

Quick and simple

I hope our guide has helped you speed up your work process and share the necessary data. Excel can really work wonders if you know how to use it effectively.

Which file format do you prefer to export to Excel and why? Share your thoughts in the comments section below.

Leave a Comment