用蚂蚁从复制源目录文件到目标目录 [英] Copying files from source directory to destination directory using ant

查看:207
本文介绍了用蚂蚁从复制源目录文件到目标目录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想用ANT从源目录某些特定的文件复制到目标目录下面的条件。

I want to copy some specific files from source directory to destination directory on below condition using ANT.

源文件夹包含以下文件


  • 35001_abc.sql

  • 38001_abc.sql

  • 38002_abc.sql

  • 39001_abc.sql

我要的文件,文件名开头的36000及以上的拷贝。

I want to copy the files with filenames starting with 36000 and above.

输出目录应包含以下文件

The Output directory should contain the following files


  • 38001_abc.sql

  • 38002_abc.sql

  • 39001_abc.sql

推荐答案

一个想法是使用正前pression的文件名来限制的数字范围。

One idea is to use a regular expression on the filename to restrict ranges of digits.

├── build.xml
├── src
│   ├── 35001_abc.sql
│   ├── 38001_abc.sql
│   ├── 38002_abc.sql
│   ├── 39001_abc.sql
│   ├── 41001_abc.sql
│   └── 46001_abc.sql
└── target
    ├── 38001_abc.sql
    ├── 38002_abc.sql
    ├── 39001_abc.sql
    ├── 41001_abc.sql
    └── 46001_abc.sql

的build.xml

<project name="demo" default="copy">

  <property name="src.dir"   location="src"/>
  <property name="build.dir" location="target"/>

  <target name="copy">
    <copy todir="${build.dir}" overwrite="true" verbose="true">
      <fileset dir="${src.dir}">
        <filename regex="^(3[6-9]|[4-9]\d)\d{3}_abc.sql$"/>
      </fileset>
    </copy>
  </target>

  <target name="clean">
    <delete dir="${build.dir}"/>
  </target>

</project>

这篇关于用蚂蚁从复制源目录文件到目标目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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