I never actually got the time to test this, but below is a response from a 
similar question :


>All,
>
>I want to delete files from a local directory that no longer exist in
>a previously mirrored directory. e.g.
>
>c:/localdir
>     file1.txt
>     file2.txt
>     file3.txt
>
>c:/otherdir
>     file1.txt
>     file3.txt
>
>In this case, I would want to delete file2.txt from c:/localdir.  Does
>anyone know if this is possible in Ant.
>

Yes, if I understood your problem correctly.

  <target name="mirror">
    <copy todir="C:\temp\test2">
      <fileset dir="C:\temp\test1"/>
    </copy>
    <delete file="C:\temp\test2\xmi2dbo.xsl"/>
    <echo>
      *** TEST1 ***
    </echo>
    <exec executable="cmd">
      <arg line="/c dir C:\temp\test1"/>
    </exec>
    <echo>
      *** TEST2 ***
    </echo>
    <exec executable="cmd">
      <arg line="/c dir C:\temp\test2"/>
    </exec>
    <echo>
      *** Files in test1 and not in test2 ***
    </echo>
    <apply executable="cmd" dest="C:\temp\test2">
      <arg value="/c"/>
      <arg value="echo"/>
      <srcfile/>
      <fileset dir="C:\temp\test1"/>
      <mapper type="identity"/>
    </apply>
  </target>

results in:

mirror:
     [copy] Copying 1 file to C:\temp\test2
   [delete] Deleting: C:\temp\test2\xmi2dbo.xsl
     [echo]
      *** TEST1 ***

     [exec]  Datenträger in Laufwerk C: ist C
     [exec]  Datenträgernummer: E49A-C096
     [exec]
     [exec]  Verzeichnis von C:\temp\test1
     [exec]
     [exec] 02.09.2001  17:35       <DIR>          .
     [exec] 02.09.2001  17:35       <DIR>          ..
     [exec] 02.09.2001  17:03               35.618 test1.xml
     [exec] 02.09.2001  17:03                4.385 test1.zargo
     [exec] 29.08.2001  11:40                   75 testfile
     [exec] 02.09.2001  17:35                1.152 xmi2dbo.xsl
     [exec]                4 Datei(en)         41.230 Bytes
     [exec]                2 Verzeichnis(se),  11.334.713.344 Bytes frei
     [echo]
      *** TEST2 ***

     [exec]  Datenträger in Laufwerk C: ist C
     [exec]  Datenträgernummer: E49A-C096
     [exec]
     [exec]  Verzeichnis von C:\temp\test2
     [exec]
     [exec] 04.09.2001  22:38       <DIR>          .
     [exec] 04.09.2001  22:38       <DIR>          ..
     [exec] 04.09.2001  22:35               35.618 test1.xml
     [exec] 04.09.2001  22:35                4.385 test1.zargo
     [exec] 04.09.2001  22:35                   75 testfile
     [exec]                3 Datei(en)         40.078 Bytes
     [exec]                2 Verzeichnis(se),  11.334.713.344 Bytes frei
     [echo]
      *** Files in test1 and not in test2 ***

    [apply] C:\temp\test1\xmi2dbo.xsl

Nico



----Original Message Follows----

>Sorry, I was not clear in my original question. Copy and Move will
>copy new files as needed, but not delete files in the destdir that no
>longer exist in sourcedir. That's the behavior I'm looking for.


_________________________________________________________________
Get your FREE download of MSN Explorer at http://explorer.msn.com/intl.asp


--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to