• 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
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

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: 25477
180
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>
 
Have you no shame? Have you no decency? Have you no tiny ad?
free, earth-friendly heat - a kickstarter for putting coin in your pocket while saving the earth
https://coderanch.com/t/751654/free-earth-friendly-heat-kickstarter
reply
    Bookmark Topic Watch Topic
  • New Topic