tags:

views:

28

answers:

1

Hello All,

I want to copy only the parent folders names from source and then create the folders with those names in a destination directory.

Ex: source - folder_1 - sub_1 - folder_2 - sub_2 - folder_3 - sub_3

destination - folder_1 - folder_2 - folder_3

Could you let me know the pattern matching for this requirement in ANT.

Regards, Satya

+1  A: 

The way to do what you ask will depend on how you intend to use the driectory list once you have it, but it sounds like you need a dirset. Here's an example build file snippet:

<property name="src.dir" value="src" />
<dirset id="my.dirset" dir="${src.dir}" includes="*"/>
<echo message="${toString:my.dirset}" />

Specifying * for the includes attribute will pick up only directories at the top-level under ${src.dir}. Then, for example, the copy task can then be used to copy those (empty) directories somewhere:

<copy todir="${dest.dir}" >
    <dirset refid="my.dirset" />
</copy>
martin clayton
Yes, that was really helpful in getting the folder names from source, but I actually wanted to create the folders with the names in ${my.dirset}
Satya
@Satya - the copy will create the directories. I doesn't copy contents, just empty directories.
martin clayton
Hi Martin, Thanks a lot. It works superb.
Satya