Dennis Buttery
Dennis Buttery

Reputation: 13

How to check if files in one directory exist in another directory?

I am looking for a means to have Ant check a target directory for the existence of files in a list/set defined by a source directory.

The Ant target only needs to determine if the files in a source directory also currently exist in the target directory. No copying/moving/deleting necessary.

Can this be done in Ant?

Upvotes: 1

Views: 289

Answers (1)

martin clayton
martin clayton

Reputation: 78225

Take a look at the Ant resource collection set operators. For example:

<fileset id="source" dir="source_dir" />
<fileset id="target" dir="target_dir" />

<difference id="difference">
    <resources refid="source"/>
    <resources refid="target"/>
</difference>

<echo message="${toString:difference}" />

You can use a dirset if you're only interested in directories.

Upvotes: 1

Related Questions