怎么用bat脚本批量读取一个txt和一个exe

2025-03-23 07:29:28
推荐回答(1个)
回答(1):

@echo off &setlocal ENABLEDELAYEDEXPANSION

cls

set /p file=请把要读取文本文档的文件夹拖入本窗口       

set /p output=请输入要生成文件的名称

for %%i in (%output%)do (

if "%%~si"=="" msg * 文件格式不对 &%0

if not "%%~xi"==".txt" msg * 文件后缀不对 -_-!!!&%0

)

if not exist %file% %0

if exist %output% del /s /q /f %output% >nul 2>nul

set id=0

for /f "tokens=*" %%i in ('dir /s /b %file%\*.txt') do (

set id+=1

set !id!=%%i

)

for /l %%i in (1,1,%id%) do (

for /f "tokens=*" %%b in (!%%i!) do (

echo %%b>>%output%

)

notepad %output%