void (File file, boolean recursively) { if (file.isDirectory()) { long start = System.currentTimeMillis(); File[] files = file.listFiles(); for (File s : files) { File dest = new File(s.getAbsolutePath() + ".tmp"); assert s.renameTo(dest) : "unable to rename " + s + " to " + dest; } long elapsed = System.currentTimeMillis() - start; System.out.println("took " + elapsed + "ms (" + elapsed / files.length + "ms per dir)"); } }