batch file - Deleating a space in the command echo !D!>>server.properties -


my .bat file looks this:

setlocal enableextensions enabledelayedexpansion setlocal enabledelayedexpansion /f "tokens=2 delims=:" %%a in ('ipconfig^|find "ipv4 address"') ( set ip=%%a goto :break )  :break echo %ip: =% >ip.txt goto :loopforcheck  :loopforcheck goto :copy if exist <ip.txt> (     goto :copy ) else (     echo failed find file     goto :loopforcheck )  :copy /f "delims=" %%i in (ip.txt) ( set "d=server-ip=%%i"   echo max-tick-time=60000> server.properties   echo server-name=unknown server>> server.properties   echo generator-settings=>> server.properties   echo force-gamemode=false>> server.properties   echo allow-nether=true>> server.properties   echo gamemode=0 >> server.properties   echo enable-query=false>> server.properties   echo player-idle-timeout=0>> server.properties   echo difficulty=1>> server.properties   echo spawn-monsters=true>> server.properties   echo op-permission-level=4>> server.properties   echo announce-player-achievements=true >> server.properties   echo pvp=true >> server.properties   echo snooper-enabled=true>> server.properties   echo level-type=default>> server.properties   echo hardcore=false>> server.properties   echo enable-command-block=true >> server.properties   echo max-players=20>> server.properties   echo network-compression-threshold=256 >> server.properties   echo resource-pack-sha1=>> server.properties   echo max-world-size=29999984>> server.properties   echo server-port=1>> server.properties   echo !d!>>server.properties   echo spawn-npcs=true>> server.properties   echo allow-flight=false>> server.properties   echo level-name=world>> server.properties   echo view-distance=10>> server.properties   echo resource-pack=>> server.properties   echo spawn-animals=true>> server.properties   echo white-list=false>> server.properties   echo generate-structures=true>> server.properties   echo online-mode=false>> server.properties   echo max-build-height=256>> server.properties   echo level-seed=assboobs>> server.properties   echo enable-rcon=false>> server.properties   echo motd=minecraft bg>> server.properties  )   )   goto :exit  :exit timeout 3 del ip.txt java -xmx3g -xms3g -jar m.jar -o false pause del server.properties 

and output server.properties this

max-tick-time=60000 server-name=unknown server generator-settings= force-gamemode=false allow-nether=true gamemode=0  enable-query=false difficulty= spawn-monsters=true announce-player-achievements=true  pvp=true  snooper-enabled=true level-type=default hardcore=false enable-command-block=true  max-players=20 network-compression-threshold=256  resource-pack-sha1= max-world-size=29999984 server-port= server-ip=192.168.2.100 <------ there space! spawn-npcs=true allow-flight=false level-name=world view-distance=10 resource-pack= spawn-animals=true white-list=false generate-structures=true online-mode=false max-build-height=256 level-seed=assboobs enable-rcon=false motd=minecraft bg 

and remove space! becouse error when run m.jar file encountered unexpected exception java.net.unknownhostexception: 192.168.2.100

echo %ip: =% removes spaces, echo %variable% >ip.txt inserts new one. attention: removing space before redirection solve it, might trouble numbers. alternative better syntax:

(echo %%ip: =%)>ip.txt 

or

>ip.txt echo %ip: =% 

Comments