Here's a more generalized version of Uwe Schindler's answer:
You can use a macrodef
to create a custom task.
<macrodef name="replaceproperty" taskname="@{taskname}">
<attribute name="src" />
<attribute name="dest" default="" />
<attribute name="replace" default="" />
<attribute name="with" default="" />
<sequential>
<loadresource property="@{dest}">
<propertyresource name="@{src}" />
<filterchain>
<tokenfilter>
<filetokenizer/>
<replacestring from="@{replace}" to="@{with}"/>
</tokenfilter>
</filterchain>
</loadresource>
</sequential>
</macrodef>
you can use this as follows:
<replaceproperty src="property1" dest="property2" replace=" " with="_"/>
this will be pretty useful if you are doing this multiple times