How to export folder content info to CSV file using PowerShell on Windows 10

Do you have a folder with a lot of files that you want to inventory in an Excel csv file? Here's a simple way to complete the task using PowerShell.

Dir Export-CSV PowerShell command
Dir Export-CSV PowerShell command

On Windows 10, sometimes, you may need to generate a csv file containing the information about a particular folder location for inventory purposes, to determine a specific information, or compare the data against another version of the folder to ensure its integrity.

You could perform this task manually, but it could take a long time. However, you can also use a PowerShell command to speed the process to a few seconds.

In this guide, you’ll learn the steps to use a PowerShell command to create an inventory of the content of a folder on Windows 10.

How to export list of files to csv on Windows 10

To create an Excel file containing files information from a folder with PowerShell, use these steps:

  1. Open File Explorer.

  2. Navigate to the folder or network location containing the files.

  3. Type the following command in the address bar and press Enter:

    PowerShell

    Open PowerShell folder location
    Open PowerShell folder location
  4. Type the following command to create an Excel supported csv list with a list of all the file names of the current location and press Enter:

    Dir | Export-CSV PATH\TO\EXPORTED\FILE.CSV

    In the command, make sure to update the path and name of the output file.

    For example, this command saves the output to the Desktop folder:

    Dir | Export-CSV C:\Users\username\Desktop\FileList.csv

    Export folder info to CSV file
    Export folder info to CSV file

Once you complete the steps, the command will create a csv file containing a lot of information about the contents inside the folder, including name of files, path, dates, and more, which you can then view and edit using Excel.

The command only creates a list of the files and folders within the current location, not subfolders.

About the author

Mauro Huculak is a Windows expert and the Editor-in-Chief who started Pureinfotech in 2010 as an independent online publication. He is also been a Windows Central contributor for nearly a decade. Mauro has over 12 years of experience writing comprehensive guides and creating professional videos about Windows, software, and related technologies, including Android and Linux. Before becoming a technology writer, he was an IT administrator for seven years. In total, Mauro has over 20 years of combined experience in technology. Throughout his career, he achieved different professional certifications from Microsoft (MSCA), Cisco (CCNP), VMware (VCP), and CompTIA (A+ and Network+), and he has been recognized as a Microsoft MVP for many years. You can follow him on X (Twitter), YouTube, LinkedIn and About.me.