Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

List directories in a folder, ignore sub directories ANT

Tags:

ant

Basically I have the following structure for a javadoc:

build
+---javadoc
+-------Module A
+-------Module B
+---Index.html

Module X are folders. I'm trying to list the folders there, ignoring subfolders, so I can create the main index. So far This is what I have:

<target name="x">
    <dirset id="dist.contents" dir="build/javadoc" excludes="build/javadoc/*/**"/>
    <property name="prop.dist.contents" refid="dist.contents"/>
    <echo>${prop.dist.contents}</echo>
</target>

But it gives me both the the Module's folder and all its subfolders. I know it should be a little detail but I can't figure it out.

like image 421
javydreamercsw Avatar asked Jul 27 '10 21:07

javydreamercsw


People also ask

How to list only the subdirectories in a directory?

Use ls command to list directories only. It is always good to do it with the familiar ls command because this is the command you use for displaying the content of a directory. To list only the subdirectories, use the -d option with ls command like this: ls -d */. Here's the output it shows:

How do I list only the contents of a specific directory?

Use ls command to list directories only. List only subdirectories in a specific directory. Use combination of ls and grep command. Use find command to list only directories. Use tree command to list only directories. Using echo command for listing directories. The ls command in Linux is used for listing the contents of any directory.

How to list only directories in Linux?

The ls command is the basic command used to list files and directories within the Linux file system. But if you want to list only directories, ls command offers some options.

How do I ignore all files with a specific name?

If you want to ignore all files with a specific name, you need to write the literal name of the file. In this case, you don't need to provide the full path to a specific file. This pattern will ignore all files with that particular name that are located anywhere in the project.


1 Answers

Change to use includes instead of excludes, and specify a wildcard that won't traverse sub-directories:

<dirset id="dist.contents" dir="build/javadoc" includes="*"/>

Further restrict the wildcard if needed:

<dirset id="dist.contents" dir="build/javadoc" includes="Module *"/>

Here's the docs on directory-based tasks.

like image 144
martin clayton Avatar answered Sep 27 '22 22:09

martin clayton