给txt文档内容开头批量插入该文档标题 批处理怎么写

给txt文档内容开头批量插入该文档标题 批处理怎么写,第1张

@echo off

set sum=0

for %%n in (*.txt) do (

cd. >content.temp

echo %%~nn >>content.temp

copy content.temp+%%n temp >nul

del /f /q content.temp >nul

del /f /q %%n

ren temp %%n

set /a sum=sum+1

)

echo 一共修改%sum%个.txt文件

pause

把上面的批处理复制到批处理文件中,然后把需要处理文件和批处理文件放在同一个文件夹下,运行在cmd运行批处理文件就ok了

保存为bat文件,放在和这些txt文件同一个文件夹里运行

@echo off

for /f "delims=" %%a in ('dir/b *.txt') do (

for /f "tokens=1* delims=:" %%b in ('findstr /n .* "%%a"') do (

if "%%b"=="1" (echo %%a%%c>>"_%%a") else echo.%%c>>"_%%a"

)

del/q "%%a"

ren "_%%a" "%%a"

)

pause


欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/bake/11929893.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2023-05-19
下一篇2023-05-19

发表评论

登录后才能评论

评论列表(0条)

    保存