ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From <Jan.Mate...@rzf.fin-nrw.de>
Subject AW: Ant exec find -exec problem
Date Thu, 16 Nov 2006 12:26:41 GMT
In Ant you should not think about what to do with each single file.
Catch all at once.

Move multiple files with   <move>
"select" old files using   <fileset><date>


Jan

>-----Urspr√ľngliche Nachricht-----
>Von: Peter Reilly [mailto:peter.kitt.reilly@gmail.com] 
>Gesendet: Mittwoch, 15. November 2006 22:14
>An: Ant Users List
>Betreff: Re: Ant exec find -exec problem
>
>three answers:
>1) you do not need to escape the args for find as
>   you are not using a shell:
><exec executable="find">
>   <line ="./feeds -name myFilename* -mtime +10 -exec mv {} 
>./feeds_backup;"/> </exec>
>2) for is only for ant1.6+ so to avoid confusion with ant1.5 it
>  is only defined in the xml task/type definitions of ant-contrib.
>  The recommended way to use this is via xml namespaces, drop
>  ant-contrib.jar into $ANT_HOME/lib or ~/.ant/lib
>  and declare the antlib namespace antlib:net.sf.antcontrib
>
><project xmlns:ac="antlib:net.sf.antcontrib">
>   <ac:for list="a,b,c,d" param="p">
>      <sequential>
>         <echo>param is @{p}</echo>
>     </sequential>
>   </ac:for>
></project>
>
>3) I normally use the shellscript task from antcontrib:
>  <ac:shellscript shell="bash">
>   find ./feeds -name myFilename* -mtime +10 -exec mv '{}' 
>./feeds_backup \;
>  </ac:shellscript>
>
>Peter
>
>On 11/15/06, Elaine Fortin <elaine_fortin@harvard.edu> wrote:
>> This looks very good. I do have antcontrib but I see that the 'for' 
>> task isn't operational. It's actually commented out in the 
>> antcontrib.properties, as "Tasks Requiring Ant 1.6 or 
>higher" and this 
>> is Ant 1.6.5 !  Huh? I will uncomment it and see if that 
>works.  Thanks!
>>
>> At 11:41 AM 11/15/2006 -0800, you wrote:
>> >I have a target in my build.xml that deletes files older 
>than 60 days.
>> >Here is how I did it purely in Ant...
>> >
>> >   <tstamp>
>> >     <format property="60_days_ago" pattern="MM/dd/yyyy hh:mm aa"
>> >offset="-60" unit="day"/>
>> >   </tstamp>
>> >
>> >   <path id="aged.archives">
>> >     <fileset dir="${archive.dir}" includes="**/*">
>> >       <date datetime="${60_days_ago}" when="before"/>
>> >     </fileset>
>> >   </path>
>> >
>> >   <target name="rmagedfiles">
>> >         <echo>Deleting files older than 60 days from the 
>archive:</echo>
>> >         <for param="file">
>> >           <path refid="aged.archives"/>
>> >           <sequential>
>> >                 <delete file="@{file}"/>
>> >       </sequential>
>> >         </for>
>> >   </target>
>> >
>> >You could easily change this to move files older than 10 days. Note 
>> >that this makes use of the <for> task from the ant-contrib project
>> >(http://ant-contrib.sourceforge.net/tasks/tasks/index.html)
>> >
>> >I hope this helps.
>> >
>> >-Rob Anderson
>> >
>> > > -----Original Message-----
>> > > From: Elaine Fortin [mailto:elaine_fortin@harvard.edu]
>> > > Sent: Wednesday, November 15, 2006 11:21 AM
>> > > To: user@ant.apache.org
>> > > Subject: Ant exec find -exec problem
>> > >
>> > > I am trying to create an Ant script to move files that 
>are 10 days 
>> > > old to a backup directory.
>> > > I cannot find how to do this purely in Ant, but I know that the 
>> > > Unix 'find'
>> > > works.
>> > >
>> > > Ant returns the error: "[exec] /bin/find: incomplete statement"
>> > >
>> > > when I issue the following:
>> > >           <exec executable="find">
>> > >                           <arg line="find ./feeds -name
>> > > myFilename* -mtime +10 -exec mv '{}' ./feeds_backup \; "/>
>> > >               </exec>
>> > >
>> > > This command works fine when issued from a Unix shell:
>> > >   find ./feeds -name myFilename* -mtime +10 -exec mv '{}'
>> > > ./feeds_backup \;
>> > >
>> > > How can I make this work?
>> > >
>> > > Thanks,
>> > > Elaine
>> > >
>> > >
>> > >
>> > > 
>------------------------------------------------------------------
>> > > --- To unsubscribe, e-mail: user-unsubscribe@ant.apache.org For 
>> > > additional commands, e-mail: user-help@ant.apache.org
>> > >
>> > >
>> > >
>> >
>> >
>> 
>>---------------------------------------------------------------------
>> >To unsubscribe, e-mail: user-unsubscribe@ant.apache.org For 
>> >additional commands, e-mail: user-help@ant.apache.org
>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@ant.apache.org For 
>additional 
>> commands, e-mail: user-help@ant.apache.org
>>
>>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: user-unsubscribe@ant.apache.org For 
>additional commands, e-mail: user-help@ant.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


Mime
View raw message