批量修改文件夹下文件的名字
// An highlighted block
public static void changeFileNameBatch(String path) {
// get file list where the path has
try {
File file = new File(path);
// get the folder list
File[] array = file.listFiles();
for (int i = 0; i < array.length; i++) {
String fileName = array[i].getName();
System.err.println(i);
/* String jp = StringUtils.substringBefore(fileName, "photo0000-");
String fileNameSuffix ="photo0000-"+StringUtils.substringAfter(fileName, "photo0000-");
String newName = new Translate().convertJptoZh(jp)+fileNameSuffix;
*/
//新的文件名字
String newName = "";
File f_new = new File(path, newName);
array[i].renameTo(f_new);
}
} catch (Exception e) {
e.printStackTrace();
System.err.println("更改失败");
}
}