Correction to the list files and folders from a directory to a file

I think you all remember OKTHEN, the one who told us all an easy way to list files and folders in a directory into a file through a context menu. He posted it as a comment. Well last day he commented on the post to correct some mistakes in the comment. Here is his new comment :

sorry i messed up a while back
cmd /c dir %1 /a /b >%1list.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 >%1list.txt

————————————————
if you don’t 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_ROOTFoldershellMake FileList]

[HKEY_CLASSES_ROOTFoldershellMake FileListcommand]
@=”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 realized 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)

I am sorry that after his comment I didn’t check the method he mentioned. Actually his methos is easier. He has made it a lot more easier this time by telling a method to do it by using a reg file.

Hi OKTHEN,
thank you very much. BTW since I don’t know your email or website I can’t contact you. So please send me your contact details if you don’t mind. If you are interested in doing a guest post please contact me..

Some related articles you may like :

  1. Add a context menu option to list all files in a folder and save it as text file
  2. What are the hidden files and folders
  3. How to add your favourite picture to Windows default wallpaper list ?
  4. Get access to all folders in Windows like Linux
  5. Universal file manager and viewer – one program for all your file types
  6. Hide files under other files (merge) using command prompt
  7. Create PDF files for free form any file by printing
  8. Batch files to automate tasks in Windows environment – tutorial

This entry was posted in Uncategorized and tagged Answer, Command Prompt/Shell, Error, Registry, Tips. Bookmark the permalink. Post a comment or leave a trackback: Trackback URL.

Post a Comment

Your email is never published nor shared. 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=""> <strike> <strong>