嘿,我現在有這個代碼把不同的文本不同的文本文件到變量,然後輸出到一個文件:批次中的每個字符串後空間輸出
@echo off
echo system starting..
cls
echo grabbing versions
cd C:\Scripts\Bamboo
FOR /F "tokens=1 delims==" %%n IN (CurrentBuild.txt) DO SET build-version-number=%%n
cd C:\Users\Administrator\bamboo-home\xml-data\build-dir\MC-CC-MAIN
FOR /F "tokens=1 delims==" %%n IN (MinecraftVersion.txt) DO SET minecraft-version-number=%%n
FOR /F "tokens=1 delims==" %%n IN (ForgeVersion.txt) DO SET forge-version-number=%%n
FOR /F "tokens=1 delims==" %%n IN (ModVersion.txt) DO SET mod-version-number=%%n
cls
echo setting versions to variables
set mod-version=mod_version = %mod-version-number%
set forge-version=forge_version = %forge-version-number%
set build-version=build_version = %build-version-number%
set minecraft-version=minecraft_version = %minecraft-version-number%
cls
echo outputing variables to build.properties
del build.properties
@echo %minecraft-version% >> build.properties
@echo %forge-version% >> build.properties
@echo %mod-version% >> build.properties
@echo %build-version% >> build.properties
cls
echo done, exiting inject script
exit
但輸出具有各一個空格(whitline) :
"minecraft_version = 1.7.10 "
"forge_version = 10.13.2.1291 "
"mod_version = v1.0 "
"build_version = 33 "
不知道爲什麼會發生這種情況。
它的工作非常感謝! – StrayanDropbear 2015-04-04 18:40:53
@ user3327050請「接受」這個答案來衡量你的感激之情。這就是StackOverflow的工作原理! – 2015-04-04 18:45:43
@Stephan是的,但是您的聲明僅適用於在「set」變量= value「'中出現的第一個」=「。而'value'包含'='這裏由空間包圍的設計! – JosefZ 2015-04-04 18:45:50