Search code examples
windowscommand-linecmddir

CMD command to get the list of only files not folders


I have around 30K files under various subfolders. I need the cmd command to print the list of all the 30K files and only the filenames not the folders.


Solution

  • edited to include file redirection

    >"x:\targetFile.txt" (for /r %a in ("x:\startFolder\*") do @echo %~nxa)
    

    Just a recursive enumeration of the files. For each file found echo to console the name and extension of the file.