@Test
public void main() throws Exception{
File file = new File("D:\\01myPrivate\\Spiders");
File[] files = file.listFiles();
my(files);
}
public void my(File[] files) throws Exception{
for(File file : files){
if(file.isDirectory()){
my(file.listFiles());
}else{
if(file.getName().endsWith("jpg")){
FileInputStream fileInputStream = new FileInputStream(file);
BufferedImage sourceImg = null;
sourceImg = ImageIO.read(fileInputStream);
fileInputStream.close();
if(sourceImg.getWidth() > sourceImg.getHeight()){
File newFile = new File("D:\\01myPrivate\\my\\"+ GUIDGenerator.javaGUID()+".jpg");
System.out.print(file.getAbsolutePath()+"——");
boolean isSuccess = file.renameTo(newFile);
System.out.println(isSuccess);
}
}
}
}
}