2
박쥐 스크립팅에 익숙하지 않아 "sampleFile.txt"라는 텍스트 파일에서 단어를 변경하려고합니다..bat 파일을 사용하여 텍스트 파일에서 단어를 바꾸는 방법은 무엇입니까?
아무도 도와 줄 수 있습니까? 이 예와 같이 아래 Thankx :
박쥐 스크립팅에 익숙하지 않아 "sampleFile.txt"라는 텍스트 파일에서 단어를 변경하려고합니다..bat 파일을 사용하여 텍스트 파일에서 단어를 바꾸는 방법은 무엇입니까?
아무도 도와 줄 수 있습니까? 이 예와 같이 아래 Thankx :
를 사용하여 배치 파일, file.txt
에 orange
와 apple
을 교체하고 newfile.txt
changefile.bat "apple" "orange" "file.txt" >"newfile.txt"
확인 DOS Batch - Find and Replace에 변경 사항을 작성하는 :
이@echo off
REM -- Prepare the Command Processor --
SETLOCAL ENABLEEXTENSIONS
SETLOCAL DISABLEDELAYEDEXPANSION
::BatchSubstitude - parses a File line by line and replaces a substring"
::syntax: BatchSubstitude.bat OldStr NewStr File
:: OldStr [in] - string to be replaced
:: NewStr [in] - string to replace with
:: File [in] - file to be parsed
:$changed 20100115
:$source http://www.dostips.com
if "%~1"=="" findstr "^::" "%~f0"&GOTO:EOF
for /f "tokens=1,* delims=]" %%A in ('"type %3|find /n /v """') do (
set "line=%%B"
if defined line (
call set "line=echo.%%line:%~1=%~2%%"
for /f "delims=" %%X in ('"echo."%%line%%""') do %%~X
) ELSE echo.
)
이 나를 위해 작동하지 않았다 . –
위의 변경된 답변을보십시오. – foxidrive