public static void main(String[] args) {
String filePath = "F:\\test\\new";
File file = new File(filePath);
File[] listFiles = file.listFiles();
for (File f1 : listFiles) {
if (f1.isFile()) {
System.out.println(f1);
String fileName = f1.getName();
if (fileName.endsWith(".zip") || fileName.endsWith(".xlsx")) {
String onlyName = fileName.replace(".zip", "").replace(".xlsx", "");
String successPath = filePath + "\\success";
File f2 = new File(successPath);
f2.mkdirs();
f1.renameTo(new File(successPath + File.separator + fileName));
f1.delete();
} else {
String failPath = filePath + "\\fail";
File f3 = new File(failPath);
f3.mkdirs();
f1.renameTo(new File(failPath + File.separator + f1.getName()));
f1.delete();
}
}
}
String filePath = "F:\\test\\new";
File file = new File(filePath);
File[] listFiles = file.listFiles();
for (File f1 : listFiles) {
if (f1.isFile()) {
System.out.println(f1);
String fileName = f1.getName();
if (fileName.endsWith(".zip") || fileName.endsWith(".xlsx")) {
String onlyName = fileName.replace(".zip", "").replace(".xlsx", "");
String successPath = filePath + "\\success";
File f2 = new File(successPath);
f2.mkdirs();
f1.renameTo(new File(successPath + File.separator + fileName));
f1.delete();
} else {
String failPath = filePath + "\\fail";
File f3 = new File(failPath);
f3.mkdirs();
f1.renameTo(new File(failPath + File.separator + f1.getName()));
f1.delete();
}
}
}