将一个目录和子目录中的所有文件复制到一个位置 [英] Copy all files from one directory and subdirectories into single location

查看:25
本文介绍了将一个目录和子目录中的所有文件复制到一个位置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我将所有 .txt 文件从一个位置复制到另一个位置的代码:

Here is my code for copying all .txt files from one location to other:

<copy todir="../new/dir">
    <fileset dir="C:/build/build">
        <include name="**/*.txt"/>
    </fileset>
</copy>

虽然它工作正常,但它正在正确复制文件,但问题是它也在目标处维护非空目录的目录结构,我想要C:/build/build"下的所有文件及其子目录应该

Altough it is working fine, it is copying files correctly but the problem is that it is maintainig the directory structure for non-empty directories at destination also, I want all the files under "C:/build/build" and its sub-directories shoul

推荐答案

根据您所写的内容,您可能想要扁平化文件?

From what you've written maybe you want to flatten the files?

http://ant.apache.org/manual/Tasks/copy.html>

<copy todir="../new/dir" flatten="true">
    <fileset dir="C:/build/build">
        <include name="**/*.txt"/>
    </fileset>
</copy>

这篇关于将一个目录和子目录中的所有文件复制到一个位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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