Ant复制文件而不会覆盖 [英] Ant copy files without overwriting

查看:119
本文介绍了Ant复制文件而不会覆盖的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

ant中是否有任何命令可以将文件从一个文件夹结构复制到另一文件夹结构,而无需检查上次修改的日期/时间是否覆盖文件.基本上,我希望从文件夹A到文件夹B的所有多余文件.也就是说:没有替换文件夹B的文件,但是文件夹A的多余文件进入了文件夹B .

Is there any command in ant to copy files from one folder structure to another without checking the last modified date/time overwriting files. Basically I want all extra files from folder A to folder B. That is: no files of folder B are replaced but extra files of folder A comes to folder B.

我看到了蚂蚁复制"和蚂蚁移动"命令,但没有帮助.有任何建议.

I saw "ant copy" and "ant move" commands, but didn't help. Any suggestions.

推荐答案

Ant的复制任务的overwrite属性状态为: 即使目标文件是较新的,也要覆盖现有文件."

Ant's copy task's overwrite attribute states: "Overwrite existing files even if the destination files are newer."

因此,将其设置为false只会阻止它们在较新的情况下被覆盖,但是在原始文件较新的情况下,无论如何它们都将被覆盖.

So setting it to false only prevents them from being overwritten if they are newer, but if the original files are newer, they overwrite no matter what.

我发现解决此问题的唯一方法是在复制之前触摸目标文件,即:

The only way i've found to get around this is to touch the destination files before copying, i.e:

<touch>
  <fileset dir="${dest.dir}"/>
</touch>
<copy todir="${dest.dir}" overwrite="false">
  <fileset dir="${src.dir}"/>
</copy>

这篇关于Ant复制文件而不会覆盖的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆