ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From <>
Subject AW: Deleting folders based upon status:(Re: AW: Checking for files in a directory)
Date Thu, 15 Mar 2007 07:18:57 GMT
>i was trying to do something like this
>Get a list of subdirectiories
>    Say my base directory is /ci ..and it has folders like 
>/ci/RL_1_5_9 , /ci/RL_1_5_10 , /ci/RL_1_5_11
>   and inturn under folder RL_1_5_9 i have 2007_15030945
>  basically i have to go through status.txt present in these
>/ci/RL_1_5_9/2007_15030945, /ci/RL_1_5_9/2007_15031000
>and if the status.txt has a string "FAIL" then I have to delete
>2007_15030945,2007_15031000 directories.
>Is there a cleaner way to do this in ANT or should I rely on 
>the not so nice
>way of having java scripts in my build.xml

Just an idea:

implement your own fileselector (this wont be a "real" selector, we've
using only the selector framework here ;)

<fileset dir="ci" includes="**/status.txt">
    <scriptselector language="javascript">
        // see manual of <scriptcondition> about predefined 
        // variables like "filename" and "file"
        // for security reasons, ignore all other files
        if (!"status.txt".equals(filename)) return true;
        // read the content and see if it failed
        content =
                  .readFully( new );
        statusHasFailed = content.contains("FAILED");
        // then delete the directory
        dir = file.getParent();

Maybe that helps. But because of deletion, try it in a small base
directory! ;-)


To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message