Saturday, November 12, 2011

Save the directory listing to a text file

Here is a useful and handy trick is to write the contents of a directory listing to a text file so you can create a report or execute a search in another tool, say Word or Excel.

I've used this in the past for other simple stuff for example, creating a spreadsheet out of a massive MP3 directory. Since I have music organized by album, each album being a directory I wanted to write the contents of My Music to a text file.

Go to CMD:
C:\User\My Music>dir *. >>Music.txt

This will list only directories and send the contents to the music.txt file. Of course you must have write permissions in the directory.

If you want a cleaner listing. Say only the directory names without any other information try:

C:\User\My Music>dir *. /b >>Music.txt

Hope it helps,
Will

No comments:

Post a Comment