Logo Background

Printing a directory listing

  • Is there a simple solution to enable the printing of a directory listing, much like that displayed when viewing a list of files on a CD or DVD? The computer is operating Windows XP.

    It’s hard to believe that Windows doesn’t actually have an easy way to do this from the Windows interface. However, there is a way to accomplish this from the Windows command-line. Go to the ‘Start’ menu > ‘Run’ and type ‘cmd’ (without the quotes) and click OK. Change to the directory from which you would like to print a listing of files. Since you mentioned you would like to do this for your CD or DVD, you will need to change to the relevant drive by typing the drive letter, followed by a colon (e.g. D:). Once you are in the directory, type the following command:
    dir /b [press ENTER]
    This will produce a ‘bare’ directory listing, which only has the file names and no other information. This is useful if you just want an index of the file names in the directory. If you need other information, type the following command:
    dir [press ENTER]
    This will list the files with their last modified date and time, size (in bytes), and full file name. So, now you have a listing, the question is what to do with this listing. First, you can copy-and-paste the listing from the command prompt window into another program, such as Notepad or Microsoft Word. First, open the program you would like to paste the text into. Then, right-click on the window toolbox icon in the top-left hand corner of the command prompt window, and select ‘Edit’ > ‘Mark’. Using the mouse, select the text within the command prompt window you would like to copy. Once this is done, right-click the toolbox again, and select ‘Edit’ > ‘Copy’. Now, paste the text into the open program.

    Unfortunately, this process involves double-handling the directory printout - once to display the information on screen, and a second time to paste it into a document. There is an easier way, where you can redirect the output of the command into a file, as opposed to on-screen. To do this, type:
    dir /b > listing.txt [press ENTER]
    or
    dir > listing.txt [press ENTER]
    depending on what information you wish to output. Don’t be alarmed that nothing displays in the command prompt window upon executing this command. Instead, the output which would usually appear in the command prompt window has instead been redirected to a text file. So, you should now see the text file ‘listing.txt’ appear in the directory for which you just created a listing, and the text file will contain the directory listing output.

    There is one flaw in this procedure - it will not work on CDs or DVDs since the command-prompt will be unable to create the ‘listings.txt’ file on the CD/DVD as it is read-only media. However, there is an easy way around this issue. We just need to tell the command prompt to create the file somewhere else. Probably the most convenient place to put the file is in a temporary folder on your C drive. Open Windows Explorer or My Computer and navigate to the root of the C drive. Then, create a folder named ‘temp’ (or something similar and equally as simple). Now, go back to the command prompt and type the command:
    dir /b > c: emplisting.txt [press ENTER]
    or
    dir > c: emplisting.txt [press ENTER]
    This will output the ‘listing.txt’ file into the C: emp directory. So, you can now visit that directory and obtain a copy of the outputted directory listing.

    While the dir command provides you with basic output, it doesn’t offer much in the way of customising of the output, and it is also a bit inconvenient to execute the command. During my research I also managed to find a program called Karen’s Directory Printer (www.karenware.com/powertools/ptdirprn.asp). This free program will allow you to create listing of directories, and is highly customisable towards the information you can output in the directory report. Depending on your requirements, this may be a better solution.

Leave a Comment
Hi there. If this is the first time you are posting a comment it will not appear immediately, but needs to be approved. This is necessary in order to combat comment spam. However, once you have submitted a comment (which is subsequently approved) you do not need to go through this process again - the site remembers who you are and auto-approves your comments. Nifty eh? Anyway, sorry about the inconvenience that this may cause for your first comment post.