ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Pascal Quesseveur" <quessev...@abaksystemes.fr>
Subject Re: selecting empty directories
Date Wed, 20 Dec 2006 13:40:42 GMT
paul.arzul writes (2006-12-20, 14:05:24):

>how do you select empty directories/folders? (a directory which has no files or
>folders in it?)

The following code uses <for> and <if> target from ant-contrib to list
empty dirs under project.dir:

    <for param="dir" >
      <dirset dir="${project.dir}" />
      <sequential>
        <pathconvert property="@{dir}.list" setonempty="no" >
          <path>
            <fileset dir="@{dir}" defaultexcludes="yes" />
          </path>
        </pathconvert>
        <if><not><isset property="@{dir}.list" /></not>
          <then>
            <echo message="@{dir} is empty" />
          </then>
        </if>
      </sequential>
    </for>

I set defaultexcludes to yes in the fileset spec to list empty dirs and dirs
containing only trash files.

HTH


--
Pascal Quesseveur, quesseveur@abaksystemes.fr


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


Mime
View raw message