You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by Leif Hanack <le...@t-systems.com> on 2003/04/01 13:34:42 UTC
Copy file or dir and changing name?
Hello,
i'm struggling with the following task and hope you have some hints and help
available.
I want to write a task that receive a file or directory and copy and rename
it.
e.g.:
./file1.txt -> ./file1_20020401_1200.txt
./file2 -> ./file2_20020401_1200
./dir1 -> ./dir1_20020401_1200
The ant call should be s.th. like:
$ant -f copy.xml -Dsource=file1.txt
$ant -f copy.xml -Dsource=dir2
So far i started with:
<?xml version="1.0"?>
<project name="copy" basedir="." default="build">
<target name="init" description="initialize ant">
<property name="source" value="test"/>
<tstamp/>
<property name="date" value="${DSTAMP}_${TSTAMP}"/>
</target>
<target name="copy" depends="init" description="">
<echo message="${source}" />
<echo message="${date}" />
<!-- copy-Task with embedded mapper regexp or glob ?? -->
</target>
<target name="build" depends="init,copy" description="">
</target>
</project>
Thanks in advance, Leif
Re: Copy file or dir and changing name?
Posted by Stefan Bodewig <bo...@apache.org>.
On Tue, 1 Apr 2003, Leif Hanack <le...@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