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: Copy file or dir and changing name?
Date Tue, 01 Apr 2003 11:50:03 GMT
I wrote a little test:

<project default="main">

    <target name="main">
        <tstamp/>
        <property name="date" value="${DSTAMP}_${TSTAMP}"/>
        <antcall target="copy"><param name="what"
value="file1.txt"/></antcall>
        <antcall target="copy"><param name="what" value="file2"/></antcall>
        <antcall target="copy"><param name="what" value="dir1"/></antcall>
    </target>



    <target name="copy" if="what">
        <available property="kind" type="dir" value="DIR" file="${what}"/>
        <property name="kind" value="FILE"/>
        <antcall target="copy-${kind}"/>
    </target>

    <target name="copy-DIR">
        <copy todir="${what}_${date}">
            <fileset dir="${what}"/>
        </copy>
    </target>

    <target name="copy-FILE">
        <copy file="${what}" tofile="${what}_${date}"/>
    </target>


</project>



The "copy"-Target does the differentiation of file and directory. That
buildfile does what
you want - besides: file1.txt is copied to file1.txt_20030401_1345 in my
test.


Jan Matèrne

> -----Urspr√ľngliche Nachricht-----
> Von: Stefan Bodewig [mailto:bodewig@apache.org]
> Gesendet am: Dienstag, 1. April 2003 13:44
> An: user@ant.apache.org
> Betreff: Re: Copy file or dir and changing name?
> 
> On Tue, 1 Apr 2003, Leif Hanack <leif.hanack@t-systems.com> wrote:
> 
> > The ant call should be s.th. like:
> > 	$ant -f copy.xml -Dsource=file1.txt
> > 	$ant -f copy.xml -Dsource=dir2
> 
> Can you use different targets for file and dir copies?  It will make
> things easier.
> 
> > So far i started with:
> 
> >         <tstamp/>
> >         <property name="date" value="${DSTAMP}_${TSTAMP}"/>
> 
> I'd rather use 
> 
>           <tstamp>
>             <format property="date" pattern="yyyyMMdd_hhmm"/>
>           </tstamp>
> 
> but that's a matter of taste.
> 
> >         <!-- copy-Task with embedded mapper regexp or glob ?? -->
> 
> definitely regexp, glob is too limitied for what you want.
> 
> Stefan
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
> For additional commands, e-mail: user-help@ant.apache.org
> 

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message