배치 파일에서 전달받은 문자열에 따옴표(")를 제거하고 싶을 때
1. %~1
파라미터로 전달된 변수는 %~n 형식으로 제거할 수 있다.
@ECHO OFFSet _string=%~1Echo the string passed to this script is %_string%
2. set replace 이용
set 명령어를 쓸 때 Y 문자열을 Z 를 대체하는 %X:Y=Z% 형식으로 처리할 수 있다.
Set _somevariable=%_somevariable:"=%
처음과 끝 따옴표만 제거하고 싶으면 아래와 같이 처리하면 된다.
:: Remove quotesSET _string=###%_string%###SET _string=%_string:"###=%SET _string=%_string:###"=%SET _string=%_string:###=%
728x90