You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by "Redondo Gallardo, Raul Maria" <rm...@eservicios.indra.es> on 2009/08/05 09:33:53 UTC

Search for folders and access them

Hello Users,

 

I'm working with a folders hierarchy and I don't know the names of the
subfolders. Is it possible with ANT to go into every subfolder which
exist or I must use an external application?

 

I want to check every folder to see if contains a certain file and do
things depending the file contained into the folder. The actions I know
how to do it with ANT, but not the way to search into all subfolders.

 

Can anyone help me?

 

Thank you very much.

 

Best regards,

 

 


RE: Search for folders and access them

Posted by "Redondo Gallardo, Raul Maria" <rm...@eservicios.indra.es>.
Thank you very very much,

I'll try it.


-----Mensaje original-----
De: Jan.Materne@rzf.fin-nrw.de [mailto:Jan.Materne@rzf.fin-nrw.de] 
Enviado el: miércoles, 05 de agosto de 2009 10:45
Para: user@ant.apache.org
Asunto: AW: Search for folders and access them

In Ant you usually have ONE action which processes a bunch of resources.
E.g. instead of iterating over a fileset and copying each individual file you
have 
  <copy todir=""><fileset.../></copy>

There are many tasks which support filesets, paths or resource collections.

A resource collection (as the most abstract type of these resources) returns resources
after a check by a "selector". 

Example: <fileset dir="."><filename regex="foo.*"/></fileset>
The file scanner scans the base directory recursively. Each file is passed to the <filename> selector
which "selects" the file if the name matches the given regular expression.

So selecting certain files is easy.
Selecting directories which contains a special "marker file" is more tricky...
  <!-- The dirset which contains only marked directories -->
  <dirset id="dirset" dir="${workingdir}">
     <present targetdir="${workingdir}">
          <mapper type="glob" from="*" to="*/${markerfile}" />
     </present>
  </dirset>
or
  <!-- The dirset which contains only marked directories -->
  <dirset id="dirset" dir="${workingdir}">
      <scriptselector language="javascript">
          if (file.isDirectory()) {
              markerName = project.getProperty("markerfile");
              markerFile = new java.io.File(file, markerName);
              self.setSelected( markerFile.exists() );
          }
      </scriptselector>
  </dirset>


Jan

>-----Ursprüngliche Nachricht-----
>Von: Redondo Gallardo, Raul Maria 
>[mailto:rmredondo@eservicios.indra.es] 
>Gesendet: Mittwoch, 5. August 2009 10:24
>An: Ant Users List
>Betreff: RE: Search for folders and access them
>
>Thank you very much Jan,
>
>In this way.... how can I process this fileset to get the path 
>to move to the folder and then do something? Is this possible?
>
>Sorry, I'm new with ANT and I've looking for the help about 
>fileset but not understand it well.
>
>Thank you very much.
>
>Raúl
>
>-----Mensaje original-----
>De: Jan.Materne@rzf.fin-nrw.de [mailto:Jan.Materne@rzf.fin-nrw.de] 
>Enviado el: miércoles, 05 de agosto de 2009 10:13
>Para: user@ant.apache.org
>Asunto: AW: Search for folders and access them
>
>Ant does "not go into" a folder.
>It scans them. 
>You could define a <fileset> which returns only the paths to 
>these files:
>
><fileset dir="." includes="**/certain.file"/>
>
>Here the wildcard "**" is interesting: every subdirectory 
>including recursive.
>If you only want the directories directly under "." choose the 
>"*" wildcard.
>
>
>Jan
>
>
>
>>-----Ursprüngliche Nachricht-----
>>Von: Redondo Gallardo, Raul Maria 
>>[mailto:rmredondo@eservicios.indra.es] 
>>Gesendet: Mittwoch, 5. August 2009 09:34
>>An: Ant Users List
>>Betreff: Search for folders and access them
>>
>>Hello Users,
>>
>> 
>>
>>I'm working with a folders hierarchy and I don't know the names of the
>>subfolders. Is it possible with ANT to go into every subfolder which
>>exist or I must use an external application?
>>
>> 
>>
>>I want to check every folder to see if contains a certain file and do
>>things depending the file contained into the folder. The 
>actions I know
>>how to do it with ANT, but not the way to search into all subfolders.
>>
>> 
>>
>>Can anyone help me?
>>
>> 
>>
>>Thank you very much.
>>
>> 
>>
>>Best regards,
>>
>> 
>>
>> 
>>
>>
>
>---------------------------------------------------------------------
>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
>
>

---------------------------------------------------------------------
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


AW: Search for folders and access them

Posted by Ja...@rzf.fin-nrw.de.
In Ant you usually have ONE action which processes a bunch of resources.
E.g. instead of iterating over a fileset and copying each individual file you
have 
  <copy todir=""><fileset.../></copy>

There are many tasks which support filesets, paths or resource collections.

A resource collection (as the most abstract type of these resources) returns resources
after a check by a "selector". 

Example: <fileset dir="."><filename regex="foo.*"/></fileset>
The file scanner scans the base directory recursively. Each file is passed to the <filename> selector
which "selects" the file if the name matches the given regular expression.

So selecting certain files is easy.
Selecting directories which contains a special "marker file" is more tricky...
  <!-- The dirset which contains only marked directories -->
  <dirset id="dirset" dir="${workingdir}">
     <present targetdir="${workingdir}">
          <mapper type="glob" from="*" to="*/${markerfile}" />
     </present>
  </dirset>
or
  <!-- The dirset which contains only marked directories -->
  <dirset id="dirset" dir="${workingdir}">
      <scriptselector language="javascript">
          if (file.isDirectory()) {
              markerName = project.getProperty("markerfile");
              markerFile = new java.io.File(file, markerName);
              self.setSelected( markerFile.exists() );
          }
      </scriptselector>
  </dirset>


Jan

>-----Ursprüngliche Nachricht-----
>Von: Redondo Gallardo, Raul Maria 
>[mailto:rmredondo@eservicios.indra.es] 
>Gesendet: Mittwoch, 5. August 2009 10:24
>An: Ant Users List
>Betreff: RE: Search for folders and access them
>
>Thank you very much Jan,
>
>In this way.... how can I process this fileset to get the path 
>to move to the folder and then do something? Is this possible?
>
>Sorry, I'm new with ANT and I've looking for the help about 
>fileset but not understand it well.
>
>Thank you very much.
>
>Raúl
>
>-----Mensaje original-----
>De: Jan.Materne@rzf.fin-nrw.de [mailto:Jan.Materne@rzf.fin-nrw.de] 
>Enviado el: miércoles, 05 de agosto de 2009 10:13
>Para: user@ant.apache.org
>Asunto: AW: Search for folders and access them
>
>Ant does "not go into" a folder.
>It scans them. 
>You could define a <fileset> which returns only the paths to 
>these files:
>
><fileset dir="." includes="**/certain.file"/>
>
>Here the wildcard "**" is interesting: every subdirectory 
>including recursive.
>If you only want the directories directly under "." choose the 
>"*" wildcard.
>
>
>Jan
>
>
>
>>-----Ursprüngliche Nachricht-----
>>Von: Redondo Gallardo, Raul Maria 
>>[mailto:rmredondo@eservicios.indra.es] 
>>Gesendet: Mittwoch, 5. August 2009 09:34
>>An: Ant Users List
>>Betreff: Search for folders and access them
>>
>>Hello Users,
>>
>> 
>>
>>I'm working with a folders hierarchy and I don't know the names of the
>>subfolders. Is it possible with ANT to go into every subfolder which
>>exist or I must use an external application?
>>
>> 
>>
>>I want to check every folder to see if contains a certain file and do
>>things depending the file contained into the folder. The 
>actions I know
>>how to do it with ANT, but not the way to search into all subfolders.
>>
>> 
>>
>>Can anyone help me?
>>
>> 
>>
>>Thank you very much.
>>
>> 
>>
>>Best regards,
>>
>> 
>>
>> 
>>
>>
>
>---------------------------------------------------------------------
>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
>
>

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


RE: Search for folders and access them

Posted by "Redondo Gallardo, Raul Maria" <rm...@eservicios.indra.es>.
Thank you very much Jan,

In this way.... how can I process this fileset to get the path to move to the folder and then do something? Is this possible?

Sorry, I'm new with ANT and I've looking for the help about fileset but not understand it well.

Thank you very much.

Raúl

-----Mensaje original-----
De: Jan.Materne@rzf.fin-nrw.de [mailto:Jan.Materne@rzf.fin-nrw.de] 
Enviado el: miércoles, 05 de agosto de 2009 10:13
Para: user@ant.apache.org
Asunto: AW: Search for folders and access them

Ant does "not go into" a folder.
It scans them. 
You could define a <fileset> which returns only the paths to these files:

<fileset dir="." includes="**/certain.file"/>

Here the wildcard "**" is interesting: every subdirectory including recursive.
If you only want the directories directly under "." choose the "*" wildcard.


Jan



>-----Ursprüngliche Nachricht-----
>Von: Redondo Gallardo, Raul Maria 
>[mailto:rmredondo@eservicios.indra.es] 
>Gesendet: Mittwoch, 5. August 2009 09:34
>An: Ant Users List
>Betreff: Search for folders and access them
>
>Hello Users,
>
> 
>
>I'm working with a folders hierarchy and I don't know the names of the
>subfolders. Is it possible with ANT to go into every subfolder which
>exist or I must use an external application?
>
> 
>
>I want to check every folder to see if contains a certain file and do
>things depending the file contained into the folder. The actions I know
>how to do it with ANT, but not the way to search into all subfolders.
>
> 
>
>Can anyone help me?
>
> 
>
>Thank you very much.
>
> 
>
>Best regards,
>
> 
>
> 
>
>

---------------------------------------------------------------------
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


AW: Search for folders and access them

Posted by Ja...@rzf.fin-nrw.de.
Ant does "not go into" a folder.
It scans them. 
You could define a <fileset> which returns only the paths to these files:

<fileset dir="." includes="**/certain.file"/>

Here the wildcard "**" is interesting: every subdirectory including recursive.
If you only want the directories directly under "." choose the "*" wildcard.


Jan



>-----Ursprüngliche Nachricht-----
>Von: Redondo Gallardo, Raul Maria 
>[mailto:rmredondo@eservicios.indra.es] 
>Gesendet: Mittwoch, 5. August 2009 09:34
>An: Ant Users List
>Betreff: Search for folders and access them
>
>Hello Users,
>
> 
>
>I'm working with a folders hierarchy and I don't know the names of the
>subfolders. Is it possible with ANT to go into every subfolder which
>exist or I must use an external application?
>
> 
>
>I want to check every folder to see if contains a certain file and do
>things depending the file contained into the folder. The actions I know
>how to do it with ANT, but not the way to search into all subfolders.
>
> 
>
>Can anyone help me?
>
> 
>
>Thank you very much.
>
> 
>
>Best regards,
>
> 
>
> 
>
>

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