How to get the list of filenames in a directory and store that in a variable using cmd commands

前端 未结 3 937
被撕碎了的回忆
被撕碎了的回忆 2020-12-16 14:45

I need to get all the filenames in a directory and store them in some variable from a command line.

I came across this

`dir /s /b > print.txt`
         


        
3条回答
  •  一向
    一向 (楼主)
    2020-12-16 14:58

    As @Matt said, use a batch file.

    setlocal enabledelayedexpansion
    set params=
    for /f "delims=" %%a in ('dir /s/b') do set params=!params! %%a 
    

提交回复
热议问题