Hello, the following untested snippet might help you.
<project>
<taskdef resource="net/sf/antcontrib/antlib.xml"/>
<for param="file">
<path>
<fileset dir="source" includes="*.xml"/>
</path>
<sequential>
<var name="basename" unset="true"/>
<basename file="@{file}" property="basename"/>
<echo>basename is ${basename}</echo>
<uptodate srcfile="source/${basename}"
targetfile="result/${basename}"
property="is.uptodate">
<if>
<not>
<isset property="is.uptodate"/>
</not>
<then>
<copy file="source/${basename}"
todir="input/${basename}">
</then>
</if>
</sequential>
</for>
</project>
An easier way will be if there is a task which
compares two filesets and returns a list with the
out-of-date files, so that list is then preprocessed,
but I do not know of such a task.
However, the docs for <copy>[1] task says: By default,
files are only copied if the source file is newer than
the destination file, or when the destination file
does not exist.
For example, if you do
<copy todir="input">
<fileset dir="source">
<include name="*.xml"/>
</fileset>
</copy>
the uptodate check will be done automatically. What
prevents you from using this, is that you have to
compare files not with the contents of <copy> dest
dir, but to a third dir.
Ivan
[1]http://ant.apache.org/manual/CoreTasks/copy.html
--- Huditsch Roman <[EMAIL PROTECTED]>
wrote:
> Hi,
>
> Thanks for the snippet!
> I found out that <var name="nameOfProperty"
> unset="true"/> you can reset a property.
>
> What I want to do is quite simple (although
> unachievable for me):
>
> I would like to copy all files from a directory
> "source", which are newer to those in "result", to
> an own directory "input".
> So, source/a.xml needs to be compared to
> result/a.xml
> source/b.xml to result/b.xml and so on....
>
> At the end, the "input" directory should just hold
> the new files...
>
> I don't know how to do this....
>
> Thanks very much for any help....
>
> kind regards,
> Roman
>
> > -----Urspr�ngliche Nachricht-----
> > Von: Ivan Ivanov
> [mailto:[EMAIL PROTECTED]
> > Gesendet: Mittwoch, 13. April 2005 13:54
> > An: Ant Users List
> > Betreff: Re: AW: [Maybe spam] Re: using file names
> >
> > Hello, I am not sure if this will do your job, but
> here is a
> > working snippet.
> > <project>
> > <taskdef resource="net/sf/antcontrib/antlib.xml"/>
> > <for param="file">
> > <path>
> > <fileset dir="${basedir}" includes="*.xml"/>
> > </path>
> > <sequential>
> > <basename file="@{file}"
> > property="@{file}.basename"/>
> > <echo>basename is [EMAIL PROTECTED]</echo>
> > </sequential>
> > </for>
> > </project>
> >
> > Here we bump in the following issue: ant
> properties are
> > immutable so if we use basename in the following
> way
> > <basename file="@{file}" property="basename"/> the
> first
> > iteration of <for> will set a property named
> "basename" and
> > all other resets of this property in the next
> iteration will
> > have no effect. That is why we append the absolute
> name of
> > the file to the name of the property to ensure
> uniqueness of
> > the proeprties'
> > names.
> >
> > However, I do not like this solution, because
> <for> is not
> > "the Ant way of doing things" so think twice
> before using it.
> > Could you provide more information what are you
> trying to
> > achieve with <for> and <uptodate>; a better idea
> might come up.
> >
> > HTH Ivan
> >
> > --- Huditsch Roman <[EMAIL PROTECTED]>
> > wrote:
> > > Ah, I see.
> > > But how can I incorporate it into an <uptodate>
> statement?
> > >
> > > <uptodate property="copy.notRequired"
> > > srcfile="@{file}">
> > > <!-- How to specify my @targetfile correctly?
> --> </uptodate>
> > >
> > > I would like to test @{file} againt the same
> basename within the
> > > "result" directory....
> > >
> > > I tried it first with "result/@{file}" which
> gave me
> > > "result/c:\Programme\test.xml".
> > >
> > > I also tried
> > > <uptodate property="copy.notRequired"
> > > srcfile="@{file}">
> > > <mapper>
> > > <flattenmapper/>
> > > <globmapper from="*" to="result/*"/>
> > > </mapper>
> > > </uptodate>
> > > but with no success either....
> > >
> > > Thanks for the help!
> > >
> > > wbr,
> > > Roman
> >
> >
> >
> >
> > __________________________________
> > Do you Yahoo!?
> > Yahoo! Small Business - Try our new resources
> site!
> > http://smallbusiness.yahoo.com/resources/
> >
> >
>
---------------------------------------------------------------------
> > To unsubscribe, e-mail:
> [EMAIL PROTECTED] For
> > additional commands, e-mail:
> [EMAIL PROTECTED]
> >
> >
>
>
---------------------------------------------------------------------
> To unsubscribe, e-mail:
> [EMAIL PROTECTED]
> For additional commands, e-mail:
> [EMAIL PROTECTED]
>
>
__________________________________
Do you Yahoo!?
Yahoo! Small Business - Try our new resources site!
http://smallbusiness.yahoo.com/resources/
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]