Print list of files under a windows directory  

Posted by Geek in

In case you want to know what files are under the directory without having to type dir command again and again, you can use this fix.

Just follow these steps:

1.Creating the simple batch file :

a) Open a plain text editor like notepad and type the following depending upon whether you want to 1)print the contents or just 2) view them .

1) For Printing the contents of directory:

Just copy and paste the following code :



dir /A:- /O:gn "%1" >c:\directory_file_list.txt
notepad /p c:/directory_file_list.txt


and the explanation of commands is as follows:

dir :provides information about files and directories under the current directory.
/A:- :Tells dir to print all the files and directories under the current directory
/O:gn :Tells dir to sort the results according to the directories and according to the names.
/p : It tells notepad command to print the file.
> : It is a redirection switch which redirects output of dir command to the text file.
"%1": It is the parameter that you provide when you select the directory.

2) To Just View the list:

copy and paste the following code:


dir /A:- /O:gn "%1" >c:\directory_file_list.txt
notepad c:/directory_file_list.txt

Notice here there is no /p (print switch) parameter along with call to notepad.


b) then save this file as "directorylist.bat" In the "C:\" Directory.


2) Adding the command to shell :

a) Open MyComputer and then goto tools menu and select folder options
b) Then Select Filetypes tab and then choose (None) " Folder " option as shown in the following figure.


































c) Then Choose advanced option at the bottom . After that choose new option from the Edit File type window.

d)Type FileList under the Action label and "C:\directorylist.bat" under the application used to perform action .


3) Press ok and apply and that should do it, in case you have problems in opening folders refer to this post .

This entry was posted on Tuesday, April 14, 2009 at Tuesday, April 14, 2009 and is filed under . You can follow any responses to this entry through the comments feed .