• 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
  • paul wheaton
  • Paul Clapham
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Roland Mueller
  • Piet Souris
Bartenders:

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
 
reply
    Bookmark Topic Watch Topic
  • New Topic