Add a context menu option to list all files in a folder and save it as text file

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

The required commands saved in a batch fileCreate 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

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.

Files listed stored automatically into a text file
In the Actions add List Files and Folders, in the Application used to do the action: add “C:\Program Files\Mine\Listfile.bat” “%1″ including the quotes. The %1 tells Windows to send the Path of the folder to our batch file when List Files and Folders option is selected.

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.

Registry Key to be added.

So the adding section is finished both the hard way and the easy way.


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.

File produced as the output listofile
This as can be seen is the result produced by dir command. This is really simple but can help us understand and tackle Windows our way. Do experiments with other options also. And if you have any doubts just contact me .

You may also want to know

70 thoughts on “Add a context menu option to list all files in a folder and save it as text file”

  1. Det funkar inte. Spårningen är inte installerad, står det på min webbplatsprofiler.Tycker det är konstigt när jag installerade programmet med er hjälp och att ni la in rätt hjälp till mig.É det något jag missat? Min andra adress fungerar, där klistrade jag in koden.

  2. I cannot believe you referred to Joanna Newsom’s “awkward baby fat.” Any comment about her weight is entirely irrelevant to a review of her album, and it’s notable that you failed to mention the appearance or weight of any of the other musicians on this

  3. ??????CHANEL????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????……??????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????

  4. ?????? ?????????????????????????????????????????1??????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????1??????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????–???????????????????????????????????????????????????????????????????????????????????????

  5. You actually make it seem so easy with your presentation but
    I find this matter to be actually something which I think I
    would never understand. It seems too complicated and very
    broad for me. I’m looking forward for your next post, I’ll try to get
    the hang of it!

  6. The following set up inicsuttrons Help!I am a digital dingbat I admit however this does not stop me..I’ve manged to down load and install this theme in my cpanel and get this blog hosted!I am unable to navigate the theme and I am assuming I need to do the I doing this in my cpanel or in wordpress dashboard?Next question if you will go to my site and click the pages.. Can you tell me whythe spacing is hap hazard???Thank you thank you thank you,JoAnn DonahueSETUP INSTRUCTIONS:1. Go into Admin >> Appearances >> Editor >> index.php and find these lines (there are 2 sets 1 for the left colum and 1 for the right column):php query_posts(’cat=1&showposts=3?);php $posts = get_posts(’category=1&numberposts=3&offset=0?);Change the category ID number (in 2 places) to the category you want to display. You can also change the number of posts that are shown (also in 2 places) although for asthetics 3 in the left column and 2 in the right column is recommended.2. To change the headings of the main content columns go into Admin >> Appearances >> Editor >> index.php and find this line (2 places) and change the text between the tags:HEADING3. To have the images show up in the left hand content column you’ll need to install the Get The Image plugin created by Justin Tadlock. You can download it here: Get The Image.

  7. Hey, I think your blog might be having browser compatibility issues.
    When I look at your blog in Chrome, it looks fine but when opening in Internet Explorer, it has some
    overlapping. I just wanted to give you a quick heads up!
    Other then that, wonderful blog!

  8. I was just looking for this info for some time. After hours of continuous Googleing, at last I got it in your site. I wonder what’s the lack of Google strategy that don’t rank this kind of informative websites in top of the list. Generally the top websites are full of garbage.

  9. 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.txt

    Paste this lstfrmt.bat file in your C:\WINDOWS folder (or any other folder in that is included in the PATH variable)

    Screenshot :
    Screenshot :

  10. 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


  11. Hi Montec, thanks for your comment. I am currently trying to do that using “find” command in Command prompt. Please subscribe to the comments so that you will get updates when the solution is found. The email subscribe form is just below the comment form.

  12. very good tip, but how do u able to display folder symbol on the end of a direcory…

    how do u able to make the dir command to display folder with a slash, dot, or folder symbol on the end to indicate it is a directory???

    dir C:/Folder it will show the folder as below

    folder1/ or make it display as folder1.. , etc
    text 1.txt
    text 2.txt

  13. hi
    how do i remove the item from the context menu? the “remove” button is greyed out in the folder options dialog.

  14. sorry i messed up awhile back
    cmd /c dir %1 /a /b >%1\list.txt

    would not only be unable to list files in folders with long file names but also it would not be able to output the list.txt to a folder with a long file name in order for it to work with long folder names, u need to use quotes around the %1’s also, if you use >> instead of > it will append to any existing list.txt in the folder you are catalogging instead of replacing the text file with a new one

    if you want to append to a pre-existing list.txt when one already exists in the output folder then use:

    cmd /c dir “%1″ /a /b /s >>”%1″\list.txt

    or if you want it to replace a possibly pre-existing list.txt in the same output folder every time

    cmd /c dir %1 /a /b >%1\list.txt

    if you dont wanna screw around in regedit
    then copy the following to a notepad document and then save it (where you can find it to click on) as listfiles.reg (NOTE make sure when u are in the save as dialog box in notepad you must use quotes around “listfiles.reg” otherwise it will loose its .reg extension and be useless)

    [Start copy below this line]

    Windows Registry Editor Version 5.00

    [HKEY_CLASSES_ROOT\Folder\shell\Make FileList]

    [HKEY_CLASSES_ROOT\Folder\shell\Make FileList\command]
    @=”cmd /c dir \”%1\” /a /b /s >>\”%1\”\\list.txt”

    [End copy above this line]

    once the above is saved into a file called “listfiles.reg”
    find the file in whatever folder you put it in
    Right click on the file, left click on Merge
    a box will ask are you sure? Yes/No click Yes

    now you have a new command available “Make FileList”
    when you right click any folder you will see this option

    if you left click on the option it will then create a new file within that folder called list.txt which contains the contents of that folder as it was each time you told it to make a list

    i realised awhile back i did not afford for long folder names but only now decided to correct it since i want to use almost the exact same thing to create a context deltree command (for quick erasure of files when i want it without using 1: shift+delete or 2: telling recycle bin to never be active keep files)

  15. 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 /k dir %1 /a /b /s >%1\list.txt

    exit registry editor

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>