假设我有一个这样的目录结构:
- 动物/狗/细节
- 动物/猫/细节
- 动物/ Frog /细节
- 动物/马/细节
使用 ant,我想将 animals
下名为 details
的所有子目录重命名为 new
。所以结果是这样的:
- 动物/狗/新
- 动物/猫/新
- 动物/ Frog /新
- 动物/马/新
我试过这样的:
<move tofile="new">
<path id="directories.to.rename">
<dirset dir="animals">
<include name="**/details"/>
</dirset>
</path>
</move>
但是得到这个错误:
Cannot concatenate multiple files into a single file.
最佳答案
您可以通过 mapper 执行您描述的重命名.例如:
<move todir="animals">
<dirset dir="animals" includes="**/details" />
<globmapper from="*/details" to="*/new"/>
</move>
(在 move
task docs 的末尾有一个类似的例子。)
您看到的错误是因为您混合了移动任务 (tofile) 的单文件模式和多文件模式。
无需将 dirset
嵌套在 path
中,因为 move
任务接受任何基于文件的资源集合,包括 dirset
.
关于java - Ant:重命名同名的子目录,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10508805/