2023年7月19日17:12:22
parent
58162c6928
commit
886c08ae1a
|
|
@ -1,6 +1,7 @@
|
||||||
package com.zhangmeng.tools.controller;
|
package com.zhangmeng.tools.controller;
|
||||||
|
|
||||||
import com.zhangmeng.tools.utils.AlertUtils;
|
import com.zhangmeng.tools.utils.AlertUtils;
|
||||||
|
import javafx.application.Platform;
|
||||||
import javafx.beans.value.ChangeListener;
|
import javafx.beans.value.ChangeListener;
|
||||||
import javafx.beans.value.ObservableValue;
|
import javafx.beans.value.ObservableValue;
|
||||||
import javafx.fxml.FXML;
|
import javafx.fxml.FXML;
|
||||||
|
|
@ -104,35 +105,43 @@ public class BatchUpdateFileNameController {
|
||||||
AtomicInteger fileCount = new AtomicInteger();
|
AtomicInteger fileCount = new AtomicInteger();
|
||||||
StringBuilder stringBuilder = new StringBuilder();
|
StringBuilder stringBuilder = new StringBuilder();
|
||||||
stringBuilder.append(System.lineSeparator());
|
stringBuilder.append(System.lineSeparator());
|
||||||
try {
|
|
||||||
Files.walkFileTree(path, new SimpleFileVisitor<Path>() {
|
|
||||||
@Override
|
|
||||||
public FileVisitResult preVisitDirectory(Path dir, BasicFileAttributes attrs) throws IOException {
|
|
||||||
dir.toString().replace(replace, replace_after);
|
|
||||||
stringBuilder.append(dir);
|
|
||||||
stringBuilder.append(System.lineSeparator());
|
|
||||||
dirCount.incrementAndGet();
|
|
||||||
return super.preVisitDirectory(dir, attrs);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
new Thread(()->{
|
||||||
public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException {
|
try {
|
||||||
String name = file.toString().replace(replace,replace_after);
|
Files.walkFileTree(path, new SimpleFileVisitor<Path>() {
|
||||||
copy_del_file(file,Paths.get(name));
|
@Override
|
||||||
stringBuilder.append(name);
|
public FileVisitResult preVisitDirectory(Path dir, BasicFileAttributes attrs) throws IOException {
|
||||||
stringBuilder.append(System.lineSeparator());
|
dir.toString().replace(replace, replace_after);
|
||||||
fileCount.incrementAndGet();
|
stringBuilder.append(dir);
|
||||||
return super.visitFile(file, attrs);
|
stringBuilder.append(System.lineSeparator());
|
||||||
}
|
dirCount.incrementAndGet();
|
||||||
});
|
return super.preVisitDirectory(dir, attrs);
|
||||||
} catch (IOException e) {
|
}
|
||||||
e.printStackTrace();
|
|
||||||
}
|
@Override
|
||||||
|
public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException {
|
||||||
|
String name = file.toString().replace(replace,replace_after);
|
||||||
|
copy_del_file(file,Paths.get(name));
|
||||||
|
stringBuilder.append(name);
|
||||||
|
stringBuilder.append(System.lineSeparator());
|
||||||
|
fileCount.incrementAndGet();
|
||||||
|
return super.visitFile(file, attrs);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}).start();
|
||||||
|
|
||||||
|
|
||||||
stringBuilder.append("文件夹数:").append(dirCount);
|
stringBuilder.append("文件夹数:").append(dirCount);
|
||||||
stringBuilder.append(System.lineSeparator());
|
stringBuilder.append(System.lineSeparator());
|
||||||
stringBuilder.append("文件数:").append(fileCount);
|
stringBuilder.append("文件数:").append(fileCount);
|
||||||
stringBuilder.append(System.lineSeparator());
|
stringBuilder.append(System.lineSeparator());
|
||||||
result_show.setText(stringBuilder.toString());
|
|
||||||
|
Platform.runLater(()->{
|
||||||
|
result_show.setText(stringBuilder.toString());
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue