How to Output the Contents of a Directory to a Text File

Well, here’s a quick little article that will show you how to export the contents of a drive or directory to a text file. One of the reasons you want to do this is to say, for example, that you have a great band. You like to show your friends all the songs you have.

To do this, you will have to do a lot of typing or take a lot of screenshots. Both can be a waste of time. Here is an easy way to create this list:

Step 1:

In Windows XP, click the start button, then run and type cmd and press enter.

If you’re using Vista, just click the Start button and type cmd in the search field.

2nd step:

You should now be looking at a black console window, also known as a shell. This applet allows us to interact with the operating system using only text commands which may seem strange to some of you, but it’s actually quite elegant.

Now if you look closely you will see that the current working path looks like C:\users\username. You don’t have to worry about that because we’ll keep this example simple.

Step 3:

Now suppose your music collection is in the Windows Vista Music folder. The full path to this folder will be C:\users\username\Music.

And we repeat that we want to save our text document to the desktop, well the full path to the desktop in Windows Vista will be C:\users\username\Desktop.

Well now we need to perform the task and to do this we type the following in the console window:

dir C:\users\username\Music >> C:\users\username\Desktop\music_list.txt

Remember to replace the username with the actual username you use for your Windows account.

The fourth step:

To help clarify, if you type dir in the console window and hit enter, you’ll see a list of files and directories stored in the current path. >> What you see is called the redirect code and basically tells the console to send the output of the dir command to another location.

It’s one of the most basic things you can do with the various console commands, but I’m sure you can see how useful it is for creating lists and analyzing the number of files in a given directory.

I hope you all enjoyed this article and found it useful.

About admin

Leave a Reply

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