okthen has commented here with an easier way if you know registry :
Go to the Folder tree My Computer\HKEY_CLASSES_ROOT\Folder\shell\ Right Click and select New»Key name the key “List Files and Folders” Now add another key to it named command. Go to the Default on right panel and double click on Default REG_SZ and paste
cmd /c dir %1 /a /b >%1\list.txt
Thanks okthen
Well the title explains it all. What we are going to do is add an option like this to the context menu (Right Click) of all folders. When you click on that the result of a dir command (all files and folders in that Filder) are listed and saved to a file name Listofile.txt in the same Folder. This file is then automatically opened. All this can be done by using simple tools available in windows itself. If you need to know more about batch files please read the . Consider reading it first if you don’t know what a batch file is.
Step 1 : Create a batch file
Create a batch file named “ListFile.bat” at “C:\Program Files\Mine\” folder (of course you can use any name and any location). Noe Right click on it and select Edit. The file will now be opened in NotePad. Enter the following lines as seen in the screen shot here. This step is common to both methods – using registry and using folderoptions menu. The commands are :
cd %1
dir /a /p /o:gen>listofile.txt
start “List of Files” notepad listofile.txt
exit
First line the batch file accepts the path of directory you clicked and changes the directory - cd to it. %1 is the argument.The second line produces the list of files and directories and redirects (>) to a file in that directory named listofile.txt , “start” starts notepad as a new process independent of the batch file and opens the listofile.txt .If you simply type notepad the process will be child of the batch file the result can be observed if you try it.
Adding an option to folder Menu
Easy way – Folder options
Goto Folder Options and select File types select New to add the new action to folder context menu.


Just restart Windows or Restart Windows Explorer and you will see the added options.
Hard Way – Registry Editing
OK so if you want a brief intro to editing registry please read the previous posts – , . Now Go to the Folder tree My Computer\HKEY_CLASSES_ROOT\Folder\shell\ Right Click and select New»Key name the key “List Files and Folders” Now add another key to it named command. Go to the Default on right panel and double click on Default REG_SZ and paste “C:\Program Files\Mine\Listfile.bat” “%1″ and save it.
.So the adding section is finished both the hard way and the easy way.
Result
Since all the hard work is done now lets go for the piece of cake. Right Click on any folder and select List Files and Folders. You will see the file named Listofiles.txt opened and the list of files inside that. The file is also saved inside the folder you selected.

You may also want to know
If you enjoyed this article, you might also like...
- Batch files to automate tasks in Windows environment – tutorial
- Correction to the list files and folders from a directory to a file
- How to add your favourite picture to Windows default wallpaper list ?
- View system files (super hidden) in Explorer
- Get access to all folders in Windows like Linux
- Hide files under other files (merge) using command prompt




Very Good Blogpost. Would you thoughts if I take a tiny snippets of your post and naturally link it to your blogposts??
Hi Jack, I have come up with the sokution to your problem.
Use the following string as default value for your command Key
cmd /c cd %1&&lstfrmt>listfile.txt&&start notepad listfile.txtPaste this lstfrmt.bat file in your C:\WINDOWS folder (or any other folder in that is included in the PATH variable)
Screenshot : http://www.exnol.com/wp-content/uploads/2007/tmp/list-file-thumb.jpg
Screenshot : http://www.exnol.com/wp-content/uploads/2007/tmp/list-files-registry-value.jpg
To Jack.
The dir command can’t solve your problem.
You can do it with wList, click my nick and get it.
wList can add backslash character to folder names as you wish.
Go: List Style – Customize – and set combo: Folder Item
Regards,
Piotr
Got it Jack. Will post it tomorrow.