开发者

Need pattern matching in Ant for copying only parent folders

开发者 https://www.devze.com 2023-01-19 06:24 出处:网络
I want to copy only the parent folders names from source and then create the folders with those names in a destination directory.

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 - fo开发者_如何学运维lder_3

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

Regards, Satya


The way to do what you ask will depend on how you intend to use the directory 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>
0

精彩评论

暂无评论...
验证码 换一张
取 消