이처럼 간단한 교체를 수행하기 위해 수백 줄의 배치 파일이 필요하지 않습니다. 두 라인의 배치 파일은 다음과 같은 작업을 수행합니다
@set @a=0 // & cscript //nologo //E:JScript "%~F0" <myfile.txt> out.txt & move /Y out.txt myfile.txt & goto :EOF
WScript.Stdout.Write(WScript.Stdin.ReadAll().replace(/HEADER/g,"\x0C"));
정규 표현식 구문의 추가 설명은 this page를 참조하십시오.
EDIT 쉽게이 프로그램을 테스트하기 위해,이 방법으로 수정할 수 있습니다에서
: 다음
@set @a=0 /*
cscript //nologo //E:JScript "%~F0" <myfile.txt> out.txt
move /Y out.txt myfile.txt
goto :EOF */
WScript.Stdout.Write(WScript.Stdin.ReadAll().replace(/HEADER/g,"\x0C"));
을 명령 프롬프트 세션을 열고 명령 줄에서 실행 화면에 오류 메시지가 나타나는지 확인하십시오. 예 :
C:>\Users\Antonio\test type myfile.txt
This is a data line
HEADER This is the first line at top of page
This is more data line
C:>\Users\Antonio\test test.bat
C:>\Users\Antonio\test cscript //nologo //E:JScript "C:\Users\Antonio\test\test.bat" 0<myfile.txt 1>out.txt
C:>\Users\Antonio\test move /Y out.txt myfile.txt
Se han movido 1 archivos.
C:>\Users\Antonio\test goto :EOF */
C:>\Users\Antonio\test type myfile.txt
This is a data line
♀ This is the first line at top of page
This is more data line
'C' = 4bits '\ x0C'로 해 보셨습니까? –
나는 아래와 같이 행운이 아니라 그것을 시도했다. 내가 그것을 실행할 때 \ x0C 파일로 문자열 'HEADER'를 대체한다는 것입니다. – Ezy
c : \ jrepl "HEADER"\ x0C/f myfile.txt/o - – Ezy