• 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
  • Tim Cooke
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Liutauras Vilda
  • Henry Wong
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Al Hobbs
  • Carey Brown
Bartenders:
  • Piet Souris
  • Mikalai Zaikin
  • Himai Minh

foreach - relative path directory listings

 
Ranch Hand
Posts: 122
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

basedir value: C:\Projects\
src.dir value: src
dirset looks in: basedir + src.dir == C:\Projects\src

Subdirectories in src:
package1
package2
package3

Resulting output:
C:\Projects\src\package1
C:\Projects\src\package2
C:\Projects\src\package3

Does anyone know how I can get a relative directory listing such that the output would be:
package1
package2
package3
 
David Duran
Ranch Hand
Posts: 122
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If you might be wondering why I need just the directory names and not the entire path, it's because I'm using the directory names by themselves as property values.
I want the property value to be "package1" and not "C:\Projects\src\package1"
 
David Duran
Ranch Hand
Posts: 122
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Here's the solution:
http://www.jguru.com/faq/view.jsp?EID=1019053
http://ant.apache.org/manual/CoreTasks/basename.html

Resulting output:
C:\Projects\src\package1
package1
C:\Projects\src\package2
package2
C:\Projects\src\package3
package3
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic