批處理指令碼 - 刪除所有空格



這用於透過替換移除字串中的所有空格。

示例

@echo off 
set str = This string    has    a  lot  of spaces 
echo %str% 

set str=%str:=% 
echo %str%

關於上文程式要注意的一個關鍵問題是,運算子 : = 用於從字串中移除所有空格。

輸出

上述命令產生如下輸出。

This string    has    a  lot  of spaces
Thisstringhasalotofspaces
batch_script_strings.htm
廣告