|
好吧,两种方法任选其一
- @echo off
- more +4 "%~0">"%Temp%\$.vbs"
- wscript /NoLogo "%Temp%\$.vbs"
- del "%Temp%\$.vbs"&goto :eof
- Set FSO = CreateObject("Scripting.FileSystemObject")
- Input = InputBox("输入替换后的字符"&vbCr&vbCr&"(取消=空)","输入","B:")
- Set File = FSO.OpenTextFile("a.txt",1)
- Str = Replace(File.ReadAll,"A:",Input)
- FSO.CreateTextFile("a1.txt",True).Write Str
- Set File = FSO.OpenTextFile("b.cmd",1)
- Str = Replace(File.ReadAll,"A:",Input)
- FSO.CreateTextFile("b1.cmd",True).Write Str
复制代码
- @echo off
- set /p In=请输入替换后的字符:
- for %%a in (a.txt b.cmd) do (
- (for /f "delims=" %%b in (%%a) do (
- set "str=%%b"
- setlocal enabledelayedexpansion
- echo,!str:A:=%In%!
- endlocal
- ))>%%~na1%%~xa
- )
复制代码 |
|