diff --git a/src/nicelee/bilibili/util/CmdUtil.java b/src/nicelee/bilibili/util/CmdUtil.java index 424fd313..15b77e52 100644 --- a/src/nicelee/bilibili/util/CmdUtil.java +++ b/src/nicelee/bilibili/util/CmdUtil.java @@ -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();