Why Create a Directory Listing

On a previous page in this section there are instructions on using the dir command to help us examine the contents of a folder. This is a particularly useful command for digital preservation as it can allow us to quickly generate a complete list of files and folders within a collection or area of our storage. Knowing what we have and where it is stored is essential for managing digital content.

On this page we will look at how to add criteria to a directory command (such as sorting the results in a particular order) and how to save the information to a separate file that can be accessed again later.

Adding Criteria to the dir Command

As mentioned above, it is possible to add criteria to the dir command to customize the information it will provide. The full of list of possible choices by typing help dir into the Command Prompt. The example command below shows some of the most useful criteria and explains what they are.


Description of an example dir command: dir /s /b /o:N

Saving the Directory Listing

To save the directory list that will be generated we need to add instructions on where to create the file, what to call it, and what file format it should be. This information is added to the end of the command after a ‘>’ symbol.

To save the file in the current folder we just need to specify the name of the file we want to create: dir /s /b /o:N > directorylist.txt

To save the file in a different folder we can specify this using a file path:
dir /s /b /o:N > C:\Archive\DirectoryLists\directorylist.txt

Saving the directory list as a text file (.txt) is a good option in the first instance. This can then potentially be loaded into a spreadsheet or database.

Now try this task for yourself by using the Command Prompt to navigate to a folder and creating a directory list for it. Consider trying it a few times with different criteria and comparing the outcomes.