Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I know I can use a wildcard to list the files in a single directory:

dir *.java

However, does anyone know if it is possible to denote a subdirectory with a wildcard as well?

I would like to do something like

dir classes/*/*.java

Where, it will list all the java files in every subdirectory beneath the classes directory.

So, if there is:


It will list all the java files within these.

Note, I'm not using this specifically for the "Dir" command, but instead another command line tool that accepts a list of files. But, if it works for Dir, it shoudl work in my other program as well.

share|improve this question

You can use dir /s *.java.

From dir /?

/S Displays files in specified directory and all subdirectories.

You will want to combine it with the /b flag which:

/B Uses bare format (no heading information or summary).

Otherwise you get a summary and header for each sub folder rather than just a list of files.

share|improve this answer

I would do this as follows:

open your command prompt, navigate to your classes directory, so your current directory is actually in classes, then type in the following command:

dir /S *.java

the /S option will tell it to recurse all sub-directories. This definitely works in dir. How it will port to whatever other tool you are using, I cannot say.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.