You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by Andy2008 <ho...@yahoo.com> on 2010/06/26 00:29:07 UTC

How to retrieve directory name

I'm looping thru a directory that contains a lot of sub directories.  I want
to get the name of each sub directory.  Below is my code

<for param="soa.project.dir">
   <path>
      <dirset dir="${svn.src.dir}">
	<present targetdir="${svn.src.dir}">
	    <mapper type="glob" from="*" to="*/${bpel.composite}" />
             </present>
     </dirset>
   </path>
<sequential>
  <echo>@{soa.project.dir}</echo>
</sequential>
</for>

Right now it outputs the whole path such as "c:\abc\def"  which is good
since I need the path but I also need the name of the subfolder too which is
"def".  The path of the folder is not fixed as in my example.  It could be a
long one too such as c:\aaa\bbb\ccc\ddd\eee\fff\def

Do you have any ideas how to get the name? 

Thanks
-- 
View this message in context: http://old.nabble.com/How-to-retrieve-directory-name-tp28997168p28997168.html
Sent from the Ant - Users mailing list archive at Nabble.com.


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


Re: How to retrieve directory name

Posted by Andy2008 <ho...@yahoo.com>.
yeah, I tried it like below.  It gave me the directory name but only the
first directory.  The value does not change for all the subsequent
directories.  Do you have any ideas?

<sequential>
  <basename property="dirName" file="@{soa.project.dir}"/>
  <echo>@{soa.project.dir} : ${dirName}</echo>
</sequential>


David Weintraub wrote:
> 
> Have you tried the <basename> task?
> 
> On Fri, Jun 25, 2010 at 6:29 PM, Andy2008 <ho...@yahoo.com> wrote:
>>
>> I'm looping thru a directory that contains a lot of sub directories.  I
>> want
>> to get the name of each sub directory.  Below is my code
>>
>> <for param="soa.project.dir">
>>   <path>
>>      <dirset dir="${svn.src.dir}">
>>        <present targetdir="${svn.src.dir}">
>>            <mapper type="glob" from="*" to="*/${bpel.composite}" />
>>             </present>
>>     </dirset>
>>   </path>
>> <sequential>
>>  <echo>@{soa.project.dir}</echo>
>> </sequential>
>> </for>
>>
>> Right now it outputs the whole path such as "c:\abc\def"  which is good
>> since I need the path but I also need the name of the subfolder too which
>> is
>> "def".  The path of the folder is not fixed as in my example.  It could
>> be a
>> long one too such as c:\aaa\bbb\ccc\ddd\eee\fff\def
>>
>> Do you have any ideas how to get the name?
>>
>> Thanks
>> --
>> View this message in context:
>> http://old.nabble.com/How-to-retrieve-directory-name-tp28997168p28997168.html
>> Sent from the Ant - Users mailing list archive at Nabble.com.
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
>> For additional commands, e-mail: user-help@ant.apache.org
>>
>>
> 
> 
> 
> -- 
> David Weintraub
> qazwart@gmail.com
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
> For additional commands, e-mail: user-help@ant.apache.org
> 
> 
> 

-- 
View this message in context: http://old.nabble.com/How-to-retrieve-directory-name-tp28997168p28997375.html
Sent from the Ant - Users mailing list archive at Nabble.com.


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


Re: How to retrieve directory name

Posted by David Weintraub <qa...@gmail.com>.
Have you tried the <basename> task?

On Fri, Jun 25, 2010 at 6:29 PM, Andy2008 <ho...@yahoo.com> wrote:
>
> I'm looping thru a directory that contains a lot of sub directories.  I want
> to get the name of each sub directory.  Below is my code
>
> <for param="soa.project.dir">
>   <path>
>      <dirset dir="${svn.src.dir}">
>        <present targetdir="${svn.src.dir}">
>            <mapper type="glob" from="*" to="*/${bpel.composite}" />
>             </present>
>     </dirset>
>   </path>
> <sequential>
>  <echo>@{soa.project.dir}</echo>
> </sequential>
> </for>
>
> Right now it outputs the whole path such as "c:\abc\def"  which is good
> since I need the path but I also need the name of the subfolder too which is
> "def".  The path of the folder is not fixed as in my example.  It could be a
> long one too such as c:\aaa\bbb\ccc\ddd\eee\fff\def
>
> Do you have any ideas how to get the name?
>
> Thanks
> --
> View this message in context: http://old.nabble.com/How-to-retrieve-directory-name-tp28997168p28997168.html
> Sent from the Ant - Users mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
> For additional commands, e-mail: user-help@ant.apache.org
>
>



-- 
David Weintraub
qazwart@gmail.com

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