import java.io.File;
import java.text.SimpleDateFormat;
import java.util.Date;
/**
* 将图片名称修改成图片属性的[修改时间]
* @author InJavaWeTrust
*/
public class ReName {
private static final String FORMAT = "yyyy年MM月dd日HH时mm分ss秒EEEE";
private static final String PATH = "E:\\InJavaWeTrust\\jpg";
public static String long2String(long l) {
Date date = new Date(l);
SimpleDateFormat sdf = new SimpleDateFormat(FORMAT);
return sdf.format(date);
}
public static void main(String[] args) {
File file = new File(PATH);
File[] files = file.listFiles();
for (File f : files) {
f.renameTo(new File(PATH + File.separator
+ long2String(f.lastModified()) + ".jpg"));
}
}
}