Home » » Generating Files and Folders List

Generating Files and Folders List

A few days ago, one of my friend asked me on how to create a list of files and folders of a directory so that he can print the list. You can do this easily by using the built-in command in Windows Command Prompt or by using some software.

Using command prompt

1. To make your work easy, open notepad or your favourite text editor.

2. In the text editor, type dir /s > output.txt.

Photobucket

 

3. Save it to a folder where you can find it easily. Make sure you save it as a .bat file. I will save it as C:\genfile.bat.

Photobucket

 

4. To generate files list of a folder, copy genfile.bat into the folder where you want to generate the files list. Then double click genfile.bat.

Context menu hack by The Elder Geek.

1. This will enable you to easily generate file list using the above .bat file from a right click menu.

Photobucket

 

2. Open Control Panel > Folder Options. Open Files Types tab.

3. Find Folder (1), then click Advanced (2).

Photobucket

 

4. In the Edit File Type dialog, click New to open the add New Action dialog.

 

The text that you enter in Action will be the name of the right click menu. Application used to perform action is the location of the .bat file that you created earlier.

Photobucket

 

5. The context menu is quite buggy and not very perfect actually. If you would like to generate files in D:\M\Metallica folder for example, you should open the Metallica folder, and right click any folder in the Metallica folder and then click the Generate File List menu (create an empty folder if there are no folder inside Metallica folder), not by right clicking the Metallica folder from D:\M.

Notes

You can customize any of these options:

- dir is a MS-DOS command to print to screen a list of files and directories in current folder.

- /s is the option to list the files in the current directory and the subdirectories.

- You can customize the output of the dir command by adding any extra options.

Displays a list of files and subdirectories in a directory.

DIR [drive:][path][filename] [/A[[:]attributes]] [/B] [/C] [/D] [/L] [/N]

  [/O[[:]sortorder]] [/P] [/Q] [/S] [/T[[:]timefield]] [/W] [/X] [/4]

  [drive:][path][filename]

              Specifies drive, directory, and/or files to list.

  /A          Displays files with specified attributes.

  attributes   D  Directories                R  Read-only files

               H  Hidden files               A  Files ready for archiving

               S  System files               -  Prefix meaning not

  /B          Uses bare format (no heading information or summary).

  /C          Display the thousand separator in file sizes.  This is the

              default.  Use /-C to disable display of separator.

  /D          Same as wide but files are list sorted by column.

  /L          Uses lowercase.

  /N          New long list format where filenames are on the far right.

  /O          List by files in sorted order.

  sortorder    N  By name (alphabetic)       S  By size (smallest first)

               E  By extension (alphabetic)  D  By date/time (oldest first)

               G  Group directories first    -  Prefix to reverse order

  /P          Pauses after each screenful of information.

  /Q          Display the owner of the file.

  /S          Displays files in specified directory and all subdirectories.

  /T          Controls which time field displayed or used for sorting

  timefield   C  Creation

              A  Last Access

              W  Last Written

  /W          Uses wide list format.

  /X          This displays the short names generated for non-8dot3 file

              names.  The format is that of /N with the short name inserted

              before the long name. If no short name is present, blanks are

              displayed in its place.

  /4          Displays four-digit years

Switches may be preset in the DIRCMD environment variable.  Override

preset switches by prefixing any switch with - (hyphen)--for example, /-W.

You can access the the options of dir command by typing dir /? in the command prompt. For example, if you want the output to be displayed in a wide format, and to include all the files in the subdirectory, use the command dir /s /w > output.txt.

- The > symbol is to make the system to save the output from dir command to a text file, which in this case, output.txt. You should not left this symbol.

- output.txt is the file name where the output will be saved.

If you want to remove the context menu that you created earlier (if you don’t like it somehow), open the registry editor (Start Menu > Run > type regedit), navigates to HKEY_CLASSES_ROOT\Folder\shell. Expand the shell entry, delete the subkey that represent the context menu entry that you add earlier (in my case, Generate File List). *WARNING* This steps involves registry editing. Make sure you know what you are doing.

Photobucket

 

Photobucket

Output generated using command prompt method

 

Using specialized software

The method above is somehow quite tricky. If you are looking for hassle-free method, there are 2 freeware that allows you to generate files and folders list easily.

 

JR Directory Printer

This simple software will generate files and folders list for you easily. The interface is very simple. Just choose the folder that you want to generate the files and folders list from, and choose what type of additional information that you want to include in the list, and press start. JR Directory Printer is freeware.

Photobucket

Photobucket

 

Photobucket

Output generated by JR Directory Printer

 

Karen’s Directory Printer

This software will provides you the ability to fully customize the output of the list of files and folders that you want to generate. You can set the program to include variety types of information to the output. This program allows you to directly print the files list. However, I think you might want to edit the output first before you print it. Karen’s Directory Printer is free and open source, written using Visual Basic 6.

Photobucket

 

Photobucket

Output generated by Karen’s Directory Printer

Tags: , , , , , ,