Ant Example: Check if a directory is empty or if specific file exists.

1. Check is empty directory:
            <if>
                 <length length="0" when="greater">
                       <fileset dir="yourDirectory" followsymlinks="false"/>
                 </length>
                 <then>
                      <!-- Dir Not Empty -->
                 </then>
                 <else>
                      <!-- Dir Empty -->
                 </else>
            </if>

 2.   Check if file exists:

    <if>
         <available file="path_to_file"/>
         <then>
              <!-- File Exists -->
         </then>
         <else>
              <!-- File Doesn't Exists -->
         </else>
    </if>

Comments

Popular posts from this blog

Django (1.2.3) CRUD Using Generic Views

Creating a Custom WebSphere Portal 8 Theme with the Eclipse IDE