Linux removing folders older than 1 year and more than 3 files
ANT selectors enable you to customize the fileset to delete.
Try the following:
<target name="purge">
<tstamp>
<format property="touch.time" pattern="MM/dd/yyyy hh:mm aa" offset="-300" unit="day"/>
</tstamp>
<delete>
<fileset dir="${src.dir}">
<date datetime="${touch.time}" when="before"/>
<scriptselector language="javascript"><![CDATA[
if (file.getParentFile().list().length > 3) {
self.setSelected(true);
}
else {
self.setSelected(false);
}
]]> </scriptselector>
</fileset>
</delete>
</target>