You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by "Graham, Marc" <MG...@sscinc.com> on 2005/11/08 20:20:46 UTC

List of directories that contain a file

Can anyone tell me how create a directory list such that each directory
contains a file with a given name? dirlist patterns test the name of the
directory. I want to test if the directory contains a file with a given
name. 

I can get the paths to the files with filelist, and then I could select
the dirnames. Do I have to iterate using foreach? How do I get the
result to be a list of directories to pass in to some other task (in
this case subant)?

Marc H. Graham
Sr. Director, Technology
SS&C Technologies
mgraham@sscinc.com

412 421 9407


RE: List of directories that contain a file

Posted by "Marc H. Graham" <dr...@bellatlantic.net>.
I can't say I understand this. And I couldn't get it to work. It seems
that it will only look in the immediate subdirectories. I need it to go
arbitrarily far down.

I ran this:

<project name="TestThings" default="test">
<taskdef resource="net/sf/antcontrib/antlib.xml">
  <classpath>
    <pathelement
location="c:/apache-ant-1.6.3/ant-contrib/lib/ant-contrib.jar"/>
  </classpath>
</taskdef>
<property name="DIR" value="k:/builddir/webheatmaps"/>
<target name="test">
   <foreach target="printme"
            param="thing">
      <path>
        <dirset  dir="${DIR}">
          <include name="*" />
          <present targetdir="${DIR}" present="both">
          <mapper type="regexp" from="(.*)" to="\1/makefile.mak" />
         </present>
       </dirset>
     </path>
    </foreach>
</target>
<target name="printme">
   <echo message="${thing}"/>
</target>
</project>

And I got (minus verbiage):

printme:
     [echo] K:\builddir\webheatmaps\Server

Despite the fact that there are four directories that I'd like to get,
viz:

WebHeatmaps>find k:/buildDir/webHeatmaps -name 'makefile.mak'
k:/buildDir/webHeatmaps/Server/makefile.mak
k:/buildDir/webHeatmaps/Server/SeverEventLogging/makefile.mak
k:/buildDir/webHeatmaps/Tunnels/IsapiTunnel/makefile.mak
k:/buildDir/webHeatmaps/Tunnels/ResourceTunnel/makefile.mak

What exactly do these things say? The dirset, without the <present>,
should be all the subdirectories of ${DIR}.  No? What exactly is the
<mapper> operating on? All the directories? 

I can't say any of this makes sense.
-----Original Message-----
From: Dominique Devienne [mailto:ddevienne@gmail.com] 
Sent: Tuesday, November 08, 2005 3:02 PM
To: Ant Users List
Subject: Re: List of directories that contain a file


> Can anyone tell me how create a directory list such that each
directory
> contains a file with a given name? dirlist patterns test the name of
the
> directory. I want to test if the directory contains a file with a
given
> name.
>
> I can get the paths to the files with filelist, and then I could
select
> the dirnames. Do I have to iterate using foreach? How do I get the
> result to be a list of directories to pass in to some other task (in
> this case subant)?

Here's an example. --DD

    <!-- Gets all the directories with a Javadoc-generated index.html
-->
    <dirset id="-docdirs" dir="${javadocs}">
      <include name="*" />
      <present targetdir="${javadocs}" present="both">
        <mapper type="regexp" from="(.*)" to="\1/index.html" />
      </present>
    </dirset>

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




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


RE: List of directories that contain a file (ignore previous message)

Posted by "Marc H. Graham" <dr...@bellatlantic.net>.
Just a matter of getting rid of the include, which was restricting it to
one level.

-----Original Message-----
From: Dominique Devienne [mailto:ddevienne@gmail.com] 
Sent: Tuesday, November 08, 2005 3:02 PM
To: Ant Users List
Subject: Re: List of directories that contain a file


> Can anyone tell me how create a directory list such that each
directory
> contains a file with a given name? dirlist patterns test the name of
the
> directory. I want to test if the directory contains a file with a
given
> name.
>
> I can get the paths to the files with filelist, and then I could
select
> the dirnames. Do I have to iterate using foreach? How do I get the
> result to be a list of directories to pass in to some other task (in
> this case subant)?

Here's an example. --DD

    <!-- Gets all the directories with a Javadoc-generated index.html
-->
    <dirset id="-docdirs" dir="${javadocs}">
      <include name="*" />
      <present targetdir="${javadocs}" present="both">
        <mapper type="regexp" from="(.*)" to="\1/index.html" />
      </present>
    </dirset>

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




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


Re: List of directories that contain a file

Posted by Dominique Devienne <dd...@gmail.com>.
> Can anyone tell me how create a directory list such that each directory
> contains a file with a given name? dirlist patterns test the name of the
> directory. I want to test if the directory contains a file with a given
> name.
>
> I can get the paths to the files with filelist, and then I could select
> the dirnames. Do I have to iterate using foreach? How do I get the
> result to be a list of directories to pass in to some other task (in
> this case subant)?

Here's an example. --DD

    <!-- Gets all the directories with a Javadoc-generated index.html -->
    <dirset id="-docdirs" dir="${javadocs}">
      <include name="*" />
      <present targetdir="${javadocs}" present="both">
        <mapper type="regexp" from="(.*)" to="\1/index.html" />
      </present>
    </dirset>

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