As mentioned in [1]

<snippet>

Copy a set of files to a directory, appending .bak to the file name on the fly

  <copy todir="../backup/dir">
    <fileset dir="src_dir"/>
    <mapper type="glob" from="*" to="*.bak"/>
  </copy>


</snippet>

Instead, <mapper type="glob" from="*" to="${DSTAMP}-*"/> will append the current date 
prior to the names of all files when copied; therefore, if you have:

a.txt
b.txt
c.txt

and you copy them using glob mapper, you will get:

YYYYMMDD-a.txt
YYYYMMDD-b.txt
YYYYMMDD-c.txt

where 'YYYYMMDD' is the current date. Obviously, you will have to use <tstamp> task 
somewhere prior to execute the task, in order let ant replace ${DSTAMP} with the 
current date. You can have more info about mappers at [2]

[1] http://ant.apache.org/manual/CoreTasks/copy.html
[2] http://ant.apache.org/manual/CoreTypes/mapper.html

HTH
Luis

-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED]
Sent: Thursday, May 13, 2004 12:36 PM
To: Conelly, Luis (GNF, Contractor)
Subject: RE: Requirement to copy from local drive to network drive 


Can you explain what this statement does ?

<mapper type="glob" from="*" to="${DSTAMP}-*"/>

Thanks in advance

-----Original Message-----
From: Conelly, Luis (GNF, Contractor) [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, May 12, 2004 7:37 AM
To: Ant Users List
Subject: RE: Requirement to copy from local drive to network drive 

I have achieved what you want with:

    <target name="copyFile">
        <copy todir="${location.target}" >
          <fileset dir="${param.mail.dist.dir}">
              <include name="**/*.zip"/>
              <include name="**/*.jar"/>
          </fileset>
          <mapper type="glob" from="*" to="${DSTAMP}-*"/>
        </copy>
    </target>

where 
${location.target} is defined as an UNC path
[\\server\sharedresource\directory]
If you define it in a properties file (as I do) you should escape the
backslashes, in order to be well-interpretated by java.util.Properties
class; otherwise, you can define it as is.

This has the advantage that works for Win and for *nix, since the path is
not hardcoded at all and can be defined for your favorite OS.

HTH
Regards
Luis

-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
Sent: Wednesday, May 12, 2004 1:03 AM
To: [EMAIL PROTECTED]
Subject: RE: Requirement to copy from local drive to network drive 


> I have a zip file . I would like to copy from my local drive 
> to my network
> drive . Can we accomplish this in Ant 1.6.1

I don�t know how you can access your network drive.
If your local machine runs under windows you can map a drive letter
via <exec executable="cmd.exe"><arg line="net use ${letter}
${unc}"/></exec>.

Maybe the <copy> supports UNC - don�t know. You should try that out.



> How to make a zip file with a time stamp .?

First <zip>, then <touch>.



Jan

Reply via email to