Browse Source

修复了爬虫模式 重命名错位的问题

剑断了 2 years ago
parent
commit
24392caf49
2 changed files with 8 additions and 4 deletions
  1. 7 3
      FileOperator.py
  2. 1 1
      main.py

+ 7 - 3
FileOperator.py

@@ -149,7 +149,7 @@ def GetSeries(dataList):
     return int(dataList.split('_')[-2])
 
 
-def DoRename(path, fileName, aID):
+def DoRename(path, fileName, aID, isLocalPattern):
     # 获取.txt文件名
     filName = fileName
     # 读取.txt文件
@@ -165,8 +165,12 @@ def DoRename(path, fileName, aID):
     for oldDir in fileList:
         filetype = '.' + oldDir.split('.')[-1]
         frontIndex = int(oldDir.split('_')[-2])
-        newDir = os.path.join(path, str(frontIndex) + '. ' + lines[index].strip('\n') + filetype)  # 新的文件路径
-        index += 1
+        if isLocalPattern:
+            newDir = os.path.join(path, str(frontIndex) + '. ' + lines[index].strip('\n') + filetype)  # 新的文件路径
+            index += 1
+        else:
+            newDir = os.path.join(path, str(frontIndex) + '. ' + lines[frontIndex-1].strip('\n') + filetype)  # 新的文件路径
+
         os.rename(oldDir, newDir)  # 重命名
 
 

+ 1 - 1
main.py

@@ -273,7 +273,7 @@ class MainApp(QMainWindow, Ui_MainWindow):
 
                     # 重命名
                     self.Log("开始重命名...")
-                    FileOperator.DoRename(outputPath, fileName, dviInfoList[2])
+                    FileOperator.DoRename(outputPath, fileName, dviInfoList[2], self.isLocalMode)
                     self.Log("重命名完毕!")
 
                     # 进度条100%