Skip to content

Commit dc33f73

Browse files
author
lichunyang
committed
批量重命名
1 parent 99fc3a9 commit dc33f73

1 file changed

Lines changed: 12 additions & 1 deletion

File tree

src/utils/FileUtils.java

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,18 @@
1919
public class FileUtils {
2020

2121
public static void main(String[] args) {
22-
getCodeLinesDetail("E:\\work\\ChildrenRead\\app\\src\\main");
22+
batchRename("E:\\work\\icons", "video_living_%s");
23+
}
24+
25+
/**
26+
* 批量重命名
27+
* @param formatter 重命名格式,xxx %s xxx,其中%s为原有名称
28+
*/
29+
private static void batchRename(String dirPath, String formatter) {
30+
for (File file : getAllFiles(dirPath)) {
31+
File newFile = new File(file.getParentFile(), String.format(formatter, file.getName()));
32+
copyFileByChannel(file, newFile);
33+
}
2334
}
2435

2536
/**

0 commit comments

Comments
 (0)