printer friendly version

Printing directory list to a file

Sometimes you might wish to share your file list with other people. Instead of typing the list yourself, use good old MS-DOS prompt to do it for you.

Even if you're not familiar with working in MS-DOS, I will try my best to explain all the commands you will need to complete this task.

Step 1: Open MS-DOS prompt

The shortcut is located here: Start > Programs > Accessories > Command Prompt. On Windows 95/98 it says MS-DOS Prompt instead of Command Prompt.

Step 2: Enter desired folder

When the window opens, your location will most likely be C:/Documents and Settings/acount name. To change this, you need the command cd (change directory). Type this:


It will get you to your root directory (C:). To go just one directory up, the command is following:


One way or another, you now have this prompt in front of you:


and it's waiting for your next command. You can enter the desired folder step by step (one directory at the time), or just copy the path from the address bar of your explorer window and type cd [paste path here], like this:

cd C:\Documents and Settings\Nelchee\My Documents

Note that Ctrl+V shortcut does not work in DOS! Right-click > choose Paste instead.

Step 3: View directory contents

Now that you're located in the desired folder, you may view it's contents. Note that you can do all this without being in the present folder, but it's a lot easier for a beginner this way.
Type dir and this will print the contents to your screen. dir /on will print it out ordered by name, in alphabetical order. dir /o-n will print it out ordered by name, in reverse alphabetical order.

If you want only the directories to be displayed, but not the files, type dir /ad

If you want subdirectories to be shown as well, type dir /ad /s

Type help dir to find out more about the possibilities of dir command.

Step 4: Print contents to a file

After you have tried out the commands, and chose one you need, you will now redirect it to a text file by adding > filename.txt on the end of your command. This example prints the contents of current directory, without timestamps and other info, folders on top followed by files, sorted by name alphabetically. Folders will be marked with parentheses []. This command won't display anything on screen, because the result will be saved to a file mylist.txt. When the prompt shows up again, it means the task was performed. If no additional message is shown, the command was succesful.

dir /d /ogn > mylist.txt

You can view the list from Windows (it's inside the folder you were printing), but you can also open it through the editor integrated in DOS, by typing:

edit mylist.txt

If you see your folder listing, you managed it :) Note that working in Editor is similar to Notepad, so you can delete and write things, and then save the file. Use the menu (File > Exit) to exit the Editor.
To close the Command Prompt window, type exit (and press enter).

Now you see how old technologies are often underestimated - there is no way to do this through Windows without using any additional software. And it leaves us, who used MS-DOS as kids, with the feeling that the true quality cannot be run over by time ;)

Share this tutorial with your friends!

Work with me

Brand identity design by Nela Dunato
Brand identity design for consulting companies

My book

The Human Centered Brand by Nela Dunato
The Human Centered Brand: A Practical Guide to Being Yourself in Business