Ant - 只复制文件而不是目录 [英] Ant - copy only file not directory

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

问题描述

我需要使用 Ant 脚本复制文件夹中除该文件夹中的目录外的所有文件.

I need to copy all files in a folder except directory in that folder using Ant script.

我使用下面的脚本来做到这一点.

Im using below script to do that.

<copy todir="targetsir">
  <fileset dir="srcdir">
     <include name="**/*.*"/>
  </fileset>
</copy>

但它会复制该文件夹中的所有文件和目录.

But it copies all files and directory in that folder.

如何限制/过滤该文件夹中的目录?

how to restrict/filter directory in that folder?

谢谢,

推荐答案

你的意思是 srcdir 包含子目录,你不想复制它们,你只想复制srcdir 下一级的文件?

Do you mean that srcdir conatins sub-directories, and you you don't want to copy them, you just want to copy the files one level beneath srcdir?

<copy todir="targetsir">
  <fileset dir="srcdir">
     <include name="*"/>
     <type type="file"/>
  </fileset>
</copy>

应该可以.您问题中的**/*.*"表示每个子目录下的每个文件".仅使用 "*" 只会匹配 srcdir 下的文件,而不是子目录.

That should work. The "**/*.*" in your question means "every file under every sub directory". Just using "*" will just match the files under srcdir, not subdirectories.

编辑以排除创建空子目录.

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

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