Embedded Basics – 3 Simple Way to Create a File Listing

Many embedded software tools require developers to feed a list of files into the tool before any magic can be performed on the code base. Whether the tools are a static code analyzer, documentation tool or even a metric analyzer, a developer has to somehow get a list of all the files contained with a project. Here are three ways to get a list of project files.

template image

File Listing Trick 1 – Using Windows Explorer

One of the easiest ways to get a file listing on a Windows based machine is to use Windows Explorer. Navigate to the top folder that contains the code base. Use the search toolbar to filter the directory for the type of file that will be contained in the listing. For example, to get all of the header files in a project directory, use *.h. Windows will take a few moments to search the directory for all of the desired file types.

Select all of the files that were found within the directory using Ctrl-A. While holding down the shift key, right click on the highlighted files and select “Copy As Path” as shown in Figure 1. A file listing document can now be opened and using Ctrl-V will paste the paths of all of the selected files. (Thanks to Dan Smith for this trick!)

File Listing Trick 2 –  Using dir

Another way to get a file listing on Windows is to use the windows shell through cmd.exe. A developer can open the shell and use the cd command to enter the directory of interest. Once in the directory of choice, a developer can use the following command to get all of the c files in the directory along with any sub directories.

dir /s *.c /b >filelist.txt

When the above command is executed, the paths for all of the c modules will be stored into the file filelist.txt in a format similar to the one listed below:


The /s switch tells dir to include all subdirectories while the /b switch tells dir to only get the file names and path and not provide any additional information. The resulting filelist.txt can easily be used with third party tools for analyzing the project.

File Listing Trick 3 –  Using find

Developers who are working on a Unix based system can use find within a terminal to get generate a file list. The find command can be used with the following syntax to get a list of all of the header and c source modules in a directory and save it to filelist.txt by using the following command:

find directory -name ‘*.c’ -o -name ‘*.h’ > filelist.txt


There are many different ways that a developer can go about getting a file list of a project under development. The three methods presented here are fairly simple and straight forward and can save a developer critical time that might otherwise have been spent writing a script that would have done the exact same thing.

Share >

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.