這篇文章主要介紹vbs如何用指定字符串替換指定內(nèi)容,文中介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們一定要看完!
代碼如下:
@echo off
setlocal enabledelayedexpansion
set file=
set /p file= 請(qǐng)輸入要操作的文件名稱(包括擴(kuò)展名):
set "file=%file:"=%"
for %%i in ("%file%") do set file=%%~fi
echo.
set replaced=
set /p replaced= 請(qǐng)輸入即將被替換的內(nèi)容:
echo.
set all=
set /p all= 請(qǐng)輸入替換字符串:
for /f "delims=" %%i in ('type "%file%"') do (
set str=%%i
set "str=!str:%replaced%=%all%!"
echo !str!>>"%file%"_tmp.txt
)
copy "%file%" "%file%"_bak.txt >nul 2>nul
move "%file%"_tmp.txt "%file%"
start "" "%file%"
以上是“vbs如何用指定字符串替換指定內(nèi)容”這篇文章的所有內(nèi)容,感謝各位的閱讀!希望分享的內(nèi)容對(duì)大家有幫助,更多相關(guān)知識(shí),歡迎關(guān)注創(chuàng)新互聯(lián)行業(yè)資訊頻道!