Batch File; List files in directory, only filenames?

前端 未结 8 1482
我在风中等你
我在风中等你 2021-01-29 22:07

This is probably a very simple question, but I\'m having trouble with it. Basically, I am trying to write a Batch File and I need it to list all the files in a certain directory

8条回答
  •  死守一世寂寞
    2021-01-29 22:18

    If you need the subdirectories too you need a "dir" command and a "For" command

    dir /b /s DIRECTORY\*.* > list1.txt
    
    for /f "tokens=*" %%A in (list1.txt) do echo %%~nxA >> list.txt
    
    del list1.txt
    

    put your root directory in dir command. It will create a list1.txt with full path names and then a list.txt with only the file names.

提交回复
热议问题