Writing java program to recursively test file naming standards

I want to write a Java application that validate files and directories according to certain naming standards. The program would let you pick a directory and would recursively analyze -- giving a list of files/directories that do not match the given rules.

Eventually I want the user to be able to input rules, but for now they would be hard coded. Oh, and this would need to be cross-platform.

I'm have a working knowledge of basic Java constructs but have no experience with libraries and have not had much luck finding demos/code samples for this type of thing.

I would love suggestions for what trees to start barking up, pseudo-code -- whatever you feel would be helpful.

EDIT: I'm not trying to remove anything here, just get a recursive listing of any names that break certain rules (e.g. no spaces or special characters, no directories that start with uppercase) in the chosen directory.


I would like to use Commons IO, I think DirectoryWalker will help you.

Here is the sample for checking and removing ".svn" dir

  public class FileCleaner extends DirectoryWalker {

    public FileCleaner() {

    public List clean(File startDirectory) {
      List results = new ArrayList();
      walk(startDirectory, results);
      return results;

    protected boolean handleDirectory(File directory, int depth, Collection results) {
      // delete svn directories and then skip
      if (".svn".equals(directory.getName())) {
        return false;
      } else {
        return true;


    protected void handleFile(File file, int depth, Collection results) {
      // delete file and add to list of deleted

Need Your Help

Unused classes in my HTML

html performance browser

Do unused class names on html elements impede rendering performance (with no corresponding style in the style).

How to make search listview android?

android listview

public class kuliner extends ListActivity {