How to Create a Text File Containing a List of File Names Using PowerShell

Body

Purpose:

This article will guide you through the steps to generate a text file that contains a list of all the file names in a specific folder using PowerShell.


Steps:

  1. Open PowerShell as Administrator:

    • Click on the Start button, type PowerShell, right-click on Windows PowerShell, and choose Run as Administrator.
  2. Navigate to the Folder:

    • Once PowerShell is open, type the following command to change the directory to the folder containing the files:
       

      powershell

      cd "C:/file/path/name"

    • Replace "C:/file/path/name" with the actual path to your folder.
    • Hit Enter.
  3. Verify Your Location:

    • You should now see the correct folder path displayed on the screen, prefixed with PS. This confirms that you're in the right location.
  4. Generate the File List:

    • To create a .txt file containing the list of file names, type the following command:
       

      powershell

      dir > relevantlabel.txt

    • Replace relevantlabel.txt with whatever you want to name your text file.
    • Hit Enter.
  5. Locate Your Text File:

    • The text file will be created in the same folder. You can find it by navigating to the folder in File Explorer.

Conclusion:

You’ve now successfully created a .txt file that contains a list of all the file names in the specified folder. 

Details

Details

Article ID: 1923
Created
Fri 10/18/24 6:13 PM
Modified
Fri 10/18/24 6:14 PM