How can I delete files in a directory that is copied from another directory?

I have two directories, say A and B. A has several files: a1, a2, a3. B also has several files: b1, b2. First, I use the following ant tasks to copy all files from B to A.

<copy todir="A" verbose="true">
    <fileset dir="B" includes="*"/>
</copy>

Then I want to undo the steps, i.e. delete files from A that are copied from B, namely b1 and b2. How can I achieve my goals?

NOTE. The file names in this example are simply used to understand the problem. I do not know the exact file names in the two directories.

+5
source share
2 answers

, FileSet , . . , :

<target name="copy" >
<copy todir="A" verbose="true">
    <fileset dir="B" includes="*"/>
</copy>
</target>

<target name="uncopy" >
<delete verbose="true">
    <fileset dir="A" >
        <present present="both" targetdir="B"/>
    </fileset>
</delete>
</target>
+7

ant, , , A, . B , A, , linux. , , , , .

, , , . B. , , , A B, . , .

0

All Articles