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

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

问题描述

我想在以下条件下使用 ANT 将一些特定文件从源目录复制到目标目录.

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

源文件夹包含以下文件

  • 350​​01_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

推荐答案

一个想法是在文件名上使用正则表达式来限制数字范围.

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>

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

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