import java.io.*;
public class RenameFiles {
public void reName(String path) {
File f = new File(path);
File[] fs = f.listFiles();
for (int i = 0; i < fs.length; ++i) {
File f2 = fs[i];
if (f2.isDirectory()) {
reName(f2.getPath());
} else {
String name = f2.getName();
f2.renameTo(new File(f2.getParent() + "/" + i+name.substring(name.lastIndexOf("."),name.length()) ));
}
}
}
public static void main(String[] args) {
RenameFiles rf = new RenameFiles();
rf.reName("E:/a4");
}
}
java批量命名文件名
最新推荐文章于 2021-06-17 09:36:46 发布