• 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
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

get a list of directories with apache ant

 
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
any one know how to get a list of directories file and file size with apache ant similar to "ls -la".
I need it quite urgent.
Thank you very very much.
 
author & internet detective
Posts: 41998
911
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ellen,
What are you dong with that data? Writing to a file or something else?

If you have to, you could use the exec task to run ls. There might be a better way depending on what you are planning to do with the output though.
 
Ellen fish
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you very very much,

Right now I have a program print out current directories, I'm try to figure out how can I make a loop and print out folders and files under each folder?
I also want to distinguish the path difference for folder and files.

Any help would be greatly appreciated.

Thank you again

<target name="test">
<exec dir="${src.dir}" executable="ls" output="dir.txt">
<arg line="-la" ></arg>
</exec>
</target>

I'm trying to work out if command "find" will work for me in both unix and windows.
and also the "dir" command, but couldn't get it to work.
<target name="test">
<exec dir="${src.dir}" executable="dir" output="dir.txt">
<arg line="* /s" ></arg>
</exec>
</target>


[ November 28, 2008: Message edited by: Ellen fish ]
[ November 28, 2008: Message edited by: Ellen fish ]
 
author
Posts: 5856
7
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think that Ant is the wrong tool for this job because it has no built-in support for this sort of thing. Perhaps a simple Java app would be better suited for your purposes. Or if you are adventurous you could look into writing an Ant task to do the job.
 
Jeanne Boyarsky
author & internet detective
Posts: 41998
911
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ellen,
I agree with Peter. Ant is a build tool. Trying to make it do much more than that is just awkward.
 
Peter Johnson
author
Posts: 5856
7
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ellen, are you by any chance trying to migrate from using makefiles to using Ant scripts? I ask because some of the questions you are asking remind me of the types of questions I asked when I made that same transition. If so, I recommend that you first learn how to do things the Ant way (for that I highly recommend the book Ant in Action) and start off with simple build scripts to learn how Ant works. I know that when I made that transition that it took me a while, and many Ant scrips, to get accustomed to doing things the Ant way. When I now look at some of the earlier Ant scripts I wrote I am thoroughly embarrassed by what a mess they are.
 
I found some pretty shells, some sea glass and this lovely tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic