need to check if filename contains the date.default property in ant script
Here is my script: `
description="--> emails any file from a specified location">
<tstamp>
<format property="date.default" pattern="yyyy-MM-dd"
offset="-1" unit="day" />
</tstamp>
<echo message="${date.default}" />
<for param="file">
<path&开发者_如何学Gogt;
<fileset dir="${report.dir}">
<include name="**/*file*.doc" />
<contains text=" ${date.default}"/>
</fileset>
</path>
</for>`
It looks like you're trying to iterate over the set of files with names that match both the word 'file' (as you use this in the include element) and the value of '${date.default}'. You probably don't need to use a selector for that - the include directive is usually enough for file name matches. For example, you might use:
<include name="**/*file*${date.default}*.doc" />
The contains
selector is for matching content of files, rather than the file names. If you have a complex filename-based matching rule, then you may need to make use of the filename
selector in combination with includes, and possibly excludes. But 'filename' selectors are normally only needed when selection is based on filename plus some other criteria.
精彩评论