Skip to content

Commit

Permalink
feat: 重命名文件失败时,尝试添加序号继续重命名。close #185
Browse files Browse the repository at this point in the history
  • Loading branch information
nICEnnnnnnnLee committed Apr 14, 2024
1 parent 18690cb commit 66f1775
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/nicelee/bilibili/util/CmdUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,17 @@ public synchronized static void convertOrAppendCmdToRenameBat(final String avid_
File folder = file.getParentFile();
if (!folder.exists())
folder.mkdirs();
originFile.renameTo(file);
if(!originFile.renameTo(file)) {// 如果不成功,大概率是文件名重复,在后面加上序号,类似于(01)
for(int i = 1; i < 100; i++) {
File f = new File(Global.savePath,
String.format("%s(%02d)%s", formattedTitle, i, tail));
Logger.println(f.getAbsolutePath());
if(!f.exists()) {
originFile.renameTo(f);
break;
}
}
}
} else {
File f = new File(Global.savePath, "rename.bat");
boolean isExist = f.exists();
Expand Down

0 comments on commit 66f1775

Please sign in to comment.