ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Nico Seessle" <n...@apache.org>
Subject Re: File deletion based on omissions from fileset.
Date Tue, 04 Sep 2001 20:40:13 GMT

----- Original Message -----
From: "Mark Gibson" <gibgob_m@hotmail.com>
To: <ant-user@jakarta.apache.org>
Sent: Tuesday, September 04, 2001 7:37 PM
Subject: File deletion based on omissions from fileset.


> 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



Mime
View raw message