How to Copy File Names in a Folder

For a folder that contains a multitude of files, it is tedious to type a list of file names by hand. If you naively attempt to highlight, copy, and paste all of the files into a text document, you will be dismayed to discover that this doesn't work. What you have actually copied are the files themselves, not their names.

To generate a text document with the list of file names (or file names plus details), you must create a Windows batch file, with the .bat extention. BAT files are executable programs that can act on batches of files, or perform repetetive operations in large batches, hence the name. The steps below will show you how to obtain a simple text list of the file names, or a text document with names plus details.

How to Generate a Simple List of File Names

(Step 1) Open Notepad or other plain text editor and enter this line of code:

dir /a /b /-p /o:gen >justnames.txt

Save this file as getnames.bat inside the folder whose files you wish to list.

(Step 2) Double click on the getnames.bat file to run the command. After about 1 second, you should see a file called justnames.txt inside the folder. When you open this file, all of the folder's files will be listed. Voilà!


How to Generate a List of File Names Plus Details

(Step 1) Open Notepad or other plain text editor and enter this line of code:

dir /a /-p /o:gen >namesdetails.txt

Save this file as getdetails.bat inside the folder whose files you wish to list.

(Step 2) Double click on the getdetails.bat file to run the command. After about 1 second, you should see a file called namesdetails.txt inside the folder. When you open this file, you will see the modification date, size in bytes, and name of each file.

(Step 3, Optional) To export the file names and details to a spreadsheet program, copy and paste the contents of namesdetails.txt into a blank Notepad document. Save this file as namesdetails.csv. The .csv file extension stands for comma separated values; it is a plain text file format that most spreadsheet programs, such as Excel, can easily import and reformat.

(Step 4, Optional) Open Excel or other spreadsheet program that you use, and click on the appropriate tabs to import the CSV file. You can now access your folder's data in an easy-to-use spreadsheet format.

© Had2Know 2010

How to Graph Functions with Excel

How to Let Website Visitors Change the Background and Text Colors

What Is My IP Address?

How to Troubleshoot a Linksys Router