How to export filenames into a text file

Export Windows folder filenames to a text file using Command Line

Export Windows folder filenames to a text file using Command Line

Scenario: You have a Windows folder containing a large amount of files that you need to have exported into one text file listing all the filenames.  For instance, you might need to copy & paste those filenames into an Excel spreadsheet.

Here’s a quick and easy way to do it:

1. Open a Command Window (Start > Run > cmd)

Open the command line

Open the command line

2. Navigate to the folder by using the cd command.   If you need to move up a level, use cd .. If your folder name contains spaces, surround it with quotations.

Commands to type

Commands to type

3. Type the command dir /b>filelist.txt

4.  This will create the text file inside that folder.  If you want the file output elsewhere, use a fully qualified name.  Remember that Windows uses \ as the directory delimiter, not /

The “pretty” alternative:  Simply drag and drop the folder into a Mozilla (Firefox) browser.  The directory structure will be output in a pretty HTML document.

Directory contents listed in an HTML page

Directory contents listed in an HTML page

15 thoughts on “How to export filenames into a text file

  1. Hi There – I’m a bit confused. When I open my dos box it says H:\>

    I want to copy files from a folder on a shared drive with the following path
    K:\Accounts Payable\Recs WA 2013\Supplier Account Recs A-M\340 – PE 30.04.2013
    What am I doing wrong, I can’t seem to get it to work?
    Thanks

  2. TRY THIS:

    You can simply paste the list into Excel, as follows:

    1. Open Windows Explorer and select the source folder in the left pane.
    2. Press Ctrl + A to select all items in the right pane.
    3. Press and hold the Shift key, then right click on the selection.
    4. From the context menu, choose “Copy as Path”.
    5. Paste the list into Excel.

Leave a Reply

Your email address will not be published. Required fields are marked *