public class IeTempFile {
public void rename() {
String path = "C:\\kennyswork\\";
File f = new File(path);
if (f.isDirectory()) {
System.out.println("path: " + path);
File[] fs = f.listFiles();
for (int i = 0; i < fs.length; i++) {
String f0 = fs[i].getName();
String f1 = f0.replaceFirst("\\[\\d+\\]", "");
System.out.print("file" + i + ": " + f0);
if (fs[i].renameTo(new File(path + f1))) {
System.out.print("...OK\n");
} else {
System.out.print("...");
}
}
} else {
System.out.println(path + " is not a directory");
}
}
public static void main(String[] args) {
new IeTempFile().rename();
}
}