We have listed the top 6 best ways to copy file names into Excel, CSV, or XML. You can additionally export folders, file lists, or trees within a specific drive or directory.
Efficiently handling file names is crucial for many tasks. In this guide, we’ll look at the top 5 practical methods to copy file names into Excel, export them as CSV lists, or generate XML files. These straightforward approaches, involving command-line tools, native Windows features, third-party tools, Excel formulas, or batch scripting, provide users with versatile options to simplify data management and analysis.
The easiest way to copy file names to Excel or export files list to XML or CSV is to use the free Folder Size application. It gives you options to customize the copied/exported files or folders and their attributes.
We will explore options to copy file names from the command line and Windows Explorer too, but using Folder Size is way easier and provides more customization options.
List of top 5 best ways to copy file names into Excel or export files list to CSV or XML:
Exporting a file directory from your computer to Excel is a great way to get an organized list of all the files in a folder. With just a few simple steps, you can create a spreadsheet containing the name, size, date modified and other details about every file in a directory.
In this article, I’ll walk you through the entire process of exporting a folder structure to Excel using Command Prompt. I’ll also provide some tips for customizing and formatting your directory spreadsheet Follow along and you’ll have a tidy Excel file listing your folder contents in no time!
Why Export a Directory to Excel?
Here are some of the benefits of exporting a folder directory to Excel:
-
See all files in one place – Rather than browsing through folders, Excel gives you a bird’s-eye view of all files in a directory.
-
Find and manage files faster – You can sort filter and search your directory spreadsheet to quickly locate files.
-
Add details not shown in File Explorer – Export folder properties like size, date modified and attributes not visible in File Explorer.
-
Customize views – Format, color code and create views in Excel to highlight important files and directories
-
Create reports – Use Excel’s pivot tables, charts and formulas to analyze storage usage, file types and more.
-
Share lists – Email Excel directory lists to colleagues rather than sharing folder access.
Step-by-Step Guide to Export a Folder Structure to Excel
Follow these steps to export a directory from File Explorer to Excel:
Open File Explorer and Command Prompt
-
Open File Explorer and navigate to the parent folder containing the directory you want to export.
-
Right click in the blank space of the folder window (not on a file) and choose “Open command window here” from the popup menu.
-
This will open a Command Prompt window already navigated to the folder directory. Leave it open.
Use a Command to List Folder Contents
-
In the Command Prompt window, type the following command and press Enter:
dir /s /b > "folderlist.txt"
-
This
dir
command with the/s
and/b
switches lists all subfolders and files in bare format redirected to a text file called folderlist.txt. -
Replace folderlist.txt with your desired filename if needed.
-
-
The text file will be created in the same folder containing the directory exported. For example if exporting C:Work FilesReports, the folderlist.txt file is saved in C:Work Files.
Import the Text File into Excel
-
Switch over to Excel and open a new blank workbook.
-
Go to the Data tab and click the
From Text
button. -
Browse to and import the folderlist.txt file you created with the
dir
command. -
In the Text Import Wizard, choose
Delimited
file type and deselect any delimited options. Click Next. -
On the next step, choose the
General
column data format and complete the import.
Refine the Excel Directory List
-
Resize the column in Excel to view the full file paths without truncating.
-
The file names will initially appear in one long column. Use the Data >
Text to Columns
tool to split the path into multiple columns by delimiter. -
Delete any blank columns like Drive Letter that aren’t needed.
-
Reorder, format and expand the columns in Excel as desired:
- File Name
- File Path
- Size (bytes)
- Date Modified
- Attributes (hidden, system, etc)
-
Apply formatting like fonts, colors and filters to customize your directory listing.
And that’s it! After following these steps you’ll have an Excel spreadsheet containing all files and folders in a directory for easy viewing and sharing.
Tips for Exporting Folders to Excel
Here are some additional tips for getting the most out of exporting a directory to Excel:
-
Add formulas to calculate total file sizes, count files by type and other metrics.
-
Color code files by type, date or other attributes (e.g. red for archives, yellow for docs).
-
Filter and sort to only show certain file types, exclusions or date ranges.
-
Use conditional formatting to highlight duplicates, large files or other criteria.
-
Include additional details like Created date, Owner and Description using
dir /s /b /a
command. -
Break down or group the list using PivotTables to analyze storage by file type, location, user, etc.
-
Refresh the import to periodically update the Excel directory listing.
-
For very large folder structures, export subdirectories to separate worksheets or workbooks.
-
Schedule and automate the folder export using Windows Task Scheduler and VBA.
Exporting a Subdirectory Tree to Excel
The steps above export a single folder’s contents into a flat Excel file listing. To export a folder tree structure with subfolders into Excel:
-
Use the
Tree
command instead ofDir
when creating the text file:tree C:MyFolder /A /F > folder-tree.txt
-
Import this text file into Excel. It will contain the nested subfolder structure.
-
Optionally use delimiters or Power Query to split the path into multiple hierarchy levels.
This exports a directory tree view showing the full subdirectory structure in Excel rather than just a single folder’s contents.
Troubleshooting Directory Exports
Here are some common issues and solutions when exporting folders to Excel:
-
Blank or truncated paths – Expand the column width in Excel to view full file paths.
-
# in paths – Use
dir /x
instead ofdir /s
to avoid # placeholder characters for maximum path length. -
Errors exporting special characters – Use a format like CSV instead of TXT to avoid issues with commas, colons, etc.
-
Files not listed – Check the source directory path, hidden/system filters and command syntax.
-
Long file names don’t export – Shorten names or use
dir /n
to list by numerical order. -
Excel crashes with large folders – Split into multiple smaller Excel files instead of one giant export.
Exporting a directory listing from File Explorer into an Excel spreadsheet provides a simple way to catalog, analyze and share folder contents. With just a few commands and clicks, you can create a customizable file and folder inventory perfect for tracking storage usage across a drive. Hopefully this article has shown you how straightforward it is to generate a directory report in Excel using the built in command line tools in Windows.
Export Files List to XML
You can export the files list in a directory to an XML file. There is an option to export all files in a folder and its subfolder to XML too.
Steps to export files list to XML:
- Scan the folder from which you want to export a list of file names.
- Click “File->Export As..”
- Choose a file name and select “XML File” for the file type.
This will export a list of all the files in the folder and all its subdirectories to an XML file. If you do not want to export the files in the subfolders, go to options and set the maximum export depth to 1. This will limit the export depth to the topmost folder.
Export All File and Folder Names to Excel
This method will let you export all file names in a directory or drive and all its subdirectories. You can export both file and folder names.
Steps to Export All File and Folder Names to Excel:
- Open Folder Size and scan the folder or drive from which you want to export.
- Click “File->Export As..” and choose a file name and select “CSV Files” for the file type.
- Open Excel click “File->Open” and choose the CSV file that you saved earlier
If you do not need the file names and only the folders you can follow this article: Top 5 Ways to Export Folder Structure to Excel, CSV List or XML
How to copy File directory to Excel Spreadsheet
How do I export a folder in Excel?
Head 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 the “.txt” format if needed and give it a different name. Now that you have the folder stricture in “.doc” format, you can import it to Excel:
What is a file directory in Excel?
A file directory in Excel is an organized master list of folder and the files they contain. Directories usually outline the names of folders and list the files saved within them. For example, the marketing department of a business may have digital folders for their end-of-quarter reports dating back to the last three years.
How do I export a list of files in Excel?
Now that you’ve created a list of files from the folders you wish to export, open your spreadsheet. Press “Ctrl+0” to open a dialog box with your available folders. Identify the folder containing the files you wish to export and select the file type drop-down menu.
How do I export data from Excel?
Instead, try the direct export method shown below: Launch Excel and open a new or existing spreadsheet. Navigate to the “Data” tab at the top of the window. Click on “Get Data” to open a dropdown menu. Select “From File,” then “From Folder.” Browse the File Explorer for the necessary folder.