Windows - A batch file to list files excluding the subfolders

April 2018




Issue


I need a batch file to list files stored in a folder but without the ones present in the subfolders?

Solution


Try this:
for %%i in (Y:\Files\*.*) do echo %%~ni >> D:\List_of_files.txt

To have a sorted list (alpahabetically).
for %%i in (Y:\Files\*.*) do echo %%~ni | sort >> D:\List_of_files.txt
Published by jak58. Latest update on October 1, 2012 at 10:56 AM by jak58.
This document, titled "Windows - A batch file to list files excluding the subfolders," is available under the Creative Commons license. Any copy, reuse, or modification of the content should be sufficiently credited to CCM (https://ccm.net/).
Error message - C:\progam1\mywebs~1\bar\2.bin\m3plugin.dll
Laptop - Print Screen key stopped working