首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >在ant-contrib for循环中为文件生成MD5

在ant-contrib for循环中为文件生成MD5
EN

Stack Overflow用户
提问于 2013-12-04 02:04:21
回答 1查看 1.2K关注 0票数 1

我正在使用文件集选择文件集,然后使用它们生成所选文件集中所有文件的校验和

这是我的脚本

代码语言:javascript
复制
<?xml version="1.0" encoding="ISO-8859-1"?>
<project name="MyTask1" basedir="." default="jar">
    <property name="cms.dir" value="D:\Test" />
    <property name="comma" value="," />
    <taskdef resource="net/sf/antcontrib/antlib.xml"/>
    <target name="A">
        <fileset id="src.files" dir="${cms.dir}" casesensitive="yes">
            <include name="**/*.uim"/>
            <include name="**/*.properties"/>
            <include name="**/*.txt"/>
        </fileset>
        <pathconvert pathsep="${line.separator}" property="sounds" refid="src.files">
            <!-- To get the names of the files only then use mapper-->
            <!--    <mapper type="flatten" />-->
        </pathconvert>
        <delete file="sounds.txt"/>
        <for list="${sounds}" delimiter="${line.separator}" param="mod">
            <sequential>
                <checksum file="@{mod}" property="MD5_Value"/>
                <echo file="sounds.txt"    append="true">@{mod}${comma}${MD5_Value}${line.separator}</echo>             
            </sequential>
        </for>
        <!--<checksum file="Test.txt" property="foobarMD5"/>-->
        <!--<echo file="sounds.txt">${foobarMD5}</echo>-->
    </target>
</project>

但是,它失败了,并且生成了重复的MD5值,这里是我的输出

D:\Test\Test1.txt,6d326741a99efbcda928e5096b43cb9a D:\Test\Test2.txt,6d326741a99efbcda928e5096b43cb9a

任何帮助..。

EN

回答 1

Stack Overflow用户

发布于 2013-12-04 07:52:29

checksum task可以处理文件集...

代码语言:javascript
复制
<checksum>
  <fileset dir=".">
    <include name="foo*"/>
  </fileset>
</checksum>

比使用for任务简单得多,for任务不是标准ANT的一部分。

票数 3
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/20358428

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档