ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Kriss" <madrockr...@hotmail.com>
Subject Re: copyng and renaming files
Date Wed, 29 Aug 2007 09:07:22 GMT
Hi,

You can use antcrontib task 'for' and the task basename, as following :

<project name="backup and copy" default="main" basedir=".">
    <property environment="env"/>
    <property name="origine.dir" value="c:\origin"/>
 <property name="dest.dir" value="c:\dest"/>
 <property name="dest.backup.dir" value="c:\dest\old"/>


 <taskdef resource="net/sf/antcontrib/antcontrib.properties"/>

 <target name="main">
  <for param="file2copy">
    <path>
      <fileset dir="${origine.dir}">
      <include name="*.java"/>
      </fileset>
    </path>
    <sequential>
    <antcall target="backupAndCopy">
     <param name="file2copy" value="@{file2copy}"/>
    </antcall>
    </sequential>
  </for>
     </target>


     <target name="backupAndCopy">
        <basename property="file2copy.filename" file="${file2copy}"/>
  <move file="${dest.dir}/${file2copy.filename}" 
tofile="${dest.backup.dir}/${file2copy.filename}"/>
  <copy file="${origine.dir}/${file2copy.filename}" 
tofile="${dest.dir}/${file2copy.filename}"/>
     </target>

</project>


Have a nice day,
kriss

----- Original Message ----- 
From: "Pomè Elisabetta" <epome@axioma.it>
To: <user@ant.apache.org>
Sent: Wednesday, August 29, 2007 10:53 AM
Subject: copyng and renaming files


> Hi everybody,
> I apologize if this issue have been posted previously, but I search the
> mailing list and I couldn't find nothing similar.
> I need to copy files (says A.java e B.java) from a directoy Origin to a
> directory Destination. The directory Destination already contains an older
> version of A.java and B.java, but it contains many other files. Before
> copying A.java and B.java (the new version) from Origin I need to save
> A.java and B.java contained in Destination in another directory
> (Destination\Old). This is my problem: I don't know how to say to ant that
> the set of fils that it have to copy from Destination to Destinatio\Old is
> the same that in contained in Origin.
> Thank you in advance for your kind reply
> Elisabetta
>
>
>
> Axioma S.p.A. www.axioma.it
> via De Vizzi 35/39 - 20092 Cinisello B.mo (MI)
> Tel. +39 02-618.061 - Fax +39 02-660.10337
>
> 


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


Mime
View raw message