• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Recursively iterate folders with Ant

 
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am wondering if this is possible to do in Ant. I want do produce a zip file for each directory that I encounter under an umbrella directory by going through all the folders under the umbrella folder recursively. e.g.

If I have the following structure:

C:\Umbrella_Folder\ABC\file1
C:\Umbrella_Folder\ABC\file2
C:\Umbrella_Folder\DEF\file3
C:\Umbrella_Folder\DEF\file4

With the above structure, I want to produce ABC.zip (which includes file1 and file2) and DEF.zip (which includes file3 and file4). Can this be done? Thanks a lot in advance.
 
Saloon Keeper
Posts: 27817
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Probably, if you use Ant+JavaScript. Ant alone isn't likely to be capable of that much programmability.
 
author
Posts: 11962
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I wrote an article on scripting Ant builds a while back. That might be of interest to you.

Having said that, I believe "the Ant way" to do something like what you're describing would be to write a custom Ant task (in Java) instead of embedding code in a scripting language.
 
drifter
Posts: 1364
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You could try using the ant-contrib tasks.

We don't use them on a regular basic, but a while back I seem to recall trying it out and it did what I wanted. Then I decided I didn't really need it.
 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
C:\Users\conor2\Desktop\JAVANE~1\NEURAL~1>type Mybuild.bat

for /d %%j in (C:\Users\conor2\Desktop\JAVANE~1\NEURAL~1\*.) do c:\users\cono
r2\desktop\javane~1\neural~1\mybuild2.bat %%j

C:\Users\conor2\Desktop\JAVANE~1\NEURAL~1>type mybuild2.bat
cd %1
c:\apache-ant-1.8.2\bin\ant
cd ..

C:\Users\conor2\Desktop\JAVANE~1\NEURAL~1>
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic