To check dirs:
<exec command="if [ -d '/path/to/dir' ]; then echo 'true'; else echo 'false'; fi;" outputProperty="output.IS_DIRECTORY_EXISTS" />
<if>
<equals arg1="${output.IS_DIRECTORY_EXISTS}" arg2="true" />
<then>
<!-- If dir exists -->
</then>
<else>
<!-- If dir doesn't exist -->
</else>
</if>
To check files:
<property name="output.IS_FILE_EXISTS" value="false" />
<exec command="if [ -f '/path/to/file' ]; then echo 'true'; else echo 'false'; fi;" outputProperty="output.IS_FILE_EXISTS" />
<if>
<equals arg1="${output.IS_FILE_EXISTS}" arg2="true" />
<then>
<!-- If file exists -->
</then>
<else>
<!-- If file doesn't exist -->
</else>
</if>