import java.io.File;
public class ModifyFileName {
public static void main(String[] args) {
File files = new File("F:/Music"); // 指定文件名及路径
int i = 1;
int j;
String chapterName;
System.out.println(files.list().length);
for (String file : files.list()) {
File tempFile = new File(files + "\\" + file);
j = i++;
chapterName = "chapter" + "0" + j + "";
File f = new File(files + "\\" + chapterName + "." + "mp3");
tempFile.renameTo(f); // 替换
}
}
}
http://www.iteye.com/topic/101631