Is There a Way to Build an Index of Files on Computers?

Unlike with traditional file systems, operating system file managers usually have a search utility.
... Jack Hollingsworth/Photodisc/Getty Images

While your computer's operating system keeps detailed information about every file on your system, it does not record this data in a form that you can easily access and use. You can, however, use your system's command interpreter to build your own listing or index of files using the Dir command. With the proper switches or command directives, you can create a text file that contains a sorted and filtered index of every single file on your system.

1 Dir Command

Dir command listing of C: drive.
... Courtesy Microsoft

Although Dir is an MSDOS command, it is still available in Windows XP, Vista, Windows 8 and Windows 8.1. This command lists all files and subdirectories within the current directory. When you launch CMD -- the Windows command prompt -- you land in your home directory. Use the "dir c:\" command to list all the files and subdirectories found in the root directory of your C: drive. To view the files within these subdirectories, however, you need to add the "/S" switch to the Dir command. Keep a permanent record of your file listing by redirecting the output of the Dir command from your monitor to a text file using the “>” symbol. The following command creates a text file called "index.txt" that contains an index of all files and directories on your C: drive:

dir c:\ /s >index.txt

2 Remove Extraneous Information

The Dir command produces a lot of information that you may not want to include in your index. For example, as each directory and subdirectory is searched, the Dir command prints header information that lists the names of each directory, file sizes, total size of all files, file creation date and time, and the number of files in each directory. You can eliminate some unnecessary text by adding the "/B," or bare format, switch. For example, the file created by the following command will contain the name and full path of each directory and file on your computer:

dir c:\ /s /b >index.txt

3 Apply Order to Results

To quickly locate certain types of files, you may want to sort your index by file type. For example, to see all of your JPG or MP3 files listed in a single section, use the "/OE" switch, which sorts the directory listing by file extension. You can also sort files by date and size. The following command creates an index of all files on your C: drive, sorted by directory and file extension:

dir c:\ /s /b /oe >index.txt

4 Remove Directory Information

You can direct the Dir command to screen out directory listings from your index by using the "/A-D" switch. The "-D" characters tell the Dir command to skip or remove directory names from its output. The "/AD" switch, however, omits file names and print directory names only. To create an index with only file names and their full paths, use the following command:

dir c:\ /s /b /oe /a-d >index.txt

Allen Bethea has written articles on programming, web design,operating systems and computer hardware since 2002. He holds a Bachelor of Science from UNC-Chapel Hill and AAS degrees in office technology, mechanical engineering/drafting and internet technology. Allen has extensive experience with desktop and system software for both Windows and Linux operating systems.

×