I want to print a numbered list of the file names in a directory.
dir /w > test.txt
What are the commands to do this?
"%%~fF" prints the full path. To print the short filename, use "%%F". See
Edit: to pass in a directory, change it to
And call it with a directory name with a following slash ("C:\Windows\", not "C:\Windows"), or with no directory name.
You could also change to the directory with
Edit: Here's a more complete, annotated version. It also lists directories -- I missed that
Simply save to a file with the extension
If using Windows with NTFS, I think this could be done with the Everything search engine. It can search for file types, with particular elements in the file name, supports regular expressions, and can export to .txt.
You can export the list of filenames using File Names Export, place numbers, format the list in any way you want and print it out.