replace 可以替換某個文件中的字符串。
<?xml version="1.0" encoding="UTF-8"?> <project name="testCondition"> <replace file="testfile1.txt" token="hello" value="world"/> </project>
結果就把 testfile1.txt 中的 "hello" 替換成了 "world".
也可以批量處理:
<?xml version="1.0" encoding="UTF-8"?> <project name="testCondition"> <replace dir="." includes="*.txt" encoding="UTF-8"> <replacefilter token="this" value="that"/> <replacefilter token="o" value="00"/> </replace> </project>
就把當前文件夾下面所有 txt 文件按照指定的 filter 替換了。