Numbering text files in a folder

前端 未结 2 951
没有蜡笔的小新
没有蜡笔的小新 2020-12-20 01:25

I have some text files placed in the same folder as a batch file. I need the batch file to echo the filenames without its extention line by line with a numbering. It has to

2条回答
  •  隐瞒了意图╮
    2020-12-20 02:10

    @echo off
    setlocal enableDelayedExpansion
    set counter=0
    for /f %%a in ('dir /b /a:-d /o:n *.txt') do (
        set /a counter=counter+1
        echo !counter! ^) %%~na
        set "fruit!counter!=%%~na"
    )
    
    echo listing fruits
    set fruit
    

提交回复
热议问题