批处理,替换(或者删除)当前文件夹中所有TXT文档中指定的字符?
1个回答
展开全部
@echo off
setlocal enabledelayedexpansion
for /f "delims=" %%i in ('dir /b "*.txt"') do (
for /f "skip=2 delims=" %%a in ('find /v "%%" "%%i"') do (
set "word1=%%a"
set "word1=!word1:123=abc!"
set "word2=!word1!"
set "word2=!word2:456=xyz!"
set "word3=!word2!"
set "word3=!word2:444=!"
echo,!word3! >>"%%~ni_tmp.txt"
)
del "%%i" /f /q
ren "%%~ni_tmp.txt" "%%i"
)
pause注:把批处理文件跟txt放在一起运行,测试前先备份好原文件
您的采纳是我们的动力和鼓励,请及时点击【采纳回答】
setlocal enabledelayedexpansion
for /f "delims=" %%i in ('dir /b "*.txt"') do (
for /f "skip=2 delims=" %%a in ('find /v "%%" "%%i"') do (
set "word1=%%a"
set "word1=!word1:123=abc!"
set "word2=!word1!"
set "word2=!word2:456=xyz!"
set "word3=!word2!"
set "word3=!word2:444=!"
echo,!word3! >>"%%~ni_tmp.txt"
)
del "%%i" /f /q
ren "%%~ni_tmp.txt" "%%i"
)
pause注:把批处理文件跟txt放在一起运行,测试前先备份好原文件
您的采纳是我们的动力和鼓励,请及时点击【采纳回答】
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询