ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Bailey, Darragh" <dbai...@hp.com>
Subject RE: Need to copy a set of files from a directory tree dynamically
Date Wed, 27 Apr 2011 09:49:55 GMT


> -----Original Message-----
> From: Ramarao_4s [mailto:phanisekhar.peri@gmail.com] 
> Sent: 26 April 2011 14:08
> To: user@ant.apache.org
> Subject: Need to copy a set of files from a directory tree dynamically
> 
> Hi All,
> 
> I have a requirement where I need to copy a set of files from 
> a directory
> tree, can any one help me in resolving this.
> 
> My directory structure is
> Ant Tesing
> + build(Folder)
> + Main(Folder)  
> + Result(Folder)
> 
> Under my Main Folder I have different sub Folders with 
> different names which
> in turn contains images folder . so my Main Folder will look like 
> Main
> + App1 (Folder)
>     + images(Folder)
>          + US-pics(Folder) (contains nevada.jpeg file)
>          + EU-pics(Folder) (contains norway.jpeg file)
> + App2 (Folder)
>    + images (Folder)
>        + Asia-pics(Folder)(contains osaka.jpeg file)	
> + App3 (Folder)
>    + images(Folder)
>          + US-pics(Folder) (contains atlanta.jpeg file)
> 
> Now my requirement is i need to copy all these jpeg images 
> from respective
> images folder to Images directory under Results folder.so my output
> directory should look like this.
> 
> Results (Folder)
>  + Images(Folder)
>       + US-pics(Folder) (contain both nevada.jpeg,atlanta.jpeg  file)
>       + EU-pics(Folder) (contains norway.jpeg file)
>       + Asia-pics(Folder)(contains osaka.jpeg file)
> 
> I need to achieve this using ant script i am trying to do 
> this using below
> script but couldn't succeed.
> 
> <copy todir="${build.home}/images">		 
>     <fileset dir="${dynamic.home}" >
> 		    	<include name="**/**/images/**/*"/>
> 		    </fileset>
> </copy>
> 
> Please help me in resolving this.


Take a look at the mapper capabilities.

Untested, but should give you an idea of the direction to go:

<copy todir="${build.home}/images">
    <fileset dir="${dynamic.home}" >
        <include name="**/images/**/*.jpeg" />
    </fileset>
    <cutdirsmapper dirs="2" />
</copy>

If you don't have ant 1.8.2, you might have to try filtermapper or regexpmapper to manipulate:
i.e. '<regexpmapper to="\1" from=".*/images/(.*)$" />' should also do similar to the
cutdirsmapper.

--
Regards,
Darragh Bailey

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


Mime
View raw message