Pārlūkot izejas kodu

【批量、转档】- 输出文件覆盖相同名称文件

liujiajie 11 mēneši atpakaļ
vecāks
revīzija
0a9f985366

+ 5 - 2
PDF Office/PDF Master/Class/Batch/Data/KMBatchBaseParameter.swift

@@ -201,8 +201,11 @@ import Cocoa
         } else {
             while fileManager.fileExists(atPath: uniqueFilePath) {
                 i += 1
-                let path = "\(filePath.deletingPathExtension)(\(i))"
-                uniqueFilePath = path.stringByAppendingPathComponent(filePath.extension)
+                var path = "\(filePath.deletingPathExtension)(\(i))"
+//                uniqueFilePath = path.stringByAppendingPathComponent(filePath.extension)
+//                path.append(".")
+                path.append(filePath.extension)
+                uniqueFilePath = path
             }
         }
         

+ 8 - 8
PDF Office/PDF Master/Class/PDFTools/Convert/NewController/Common/KMPDFConvert.swift

@@ -127,15 +127,15 @@ class KMPDFConvert: Operation {
         
         
         if convertType == .jpeg || convertType == .jpg || convertType == .png || convertType == .gif || convertType == .tga || convertType == .bmp || convertType == .jp2 || convertType == .tiff {
-            if (self.convertType == .jpeg || self.convertType == .png) {
-                self.outputFilePath = "\(path)/\(fileName).zip"
-            } else {
+//            if (self.convertType == .jpeg || self.convertType == .png) {
+//                self.outputFilePath = "\(path)/\(fileName).zip"
+//            } else {
                 path.append("/")
                 path.append(fileName)
-    //            let folderPath = getUniqueFilePath(filePath: path)
+                let folderPath = getUniqueFilePath(filePath: path)
                 try?FileManager.default.createDirectory(atPath: path, withIntermediateDirectories: false)
-                outputFilePath = path
-            }
+                outputFilePath = folderPath
+//            }
         } else {
             if !pathExtension.isEmpty {
                 fileName.append(".")
@@ -143,9 +143,9 @@ class KMPDFConvert: Operation {
                 
                 path.append("/")
                 path.append(fileName)
-//                let folderPath = getUniqueFilePath(filePath: path)
+                let folderPath = getUniqueFilePath(filePath: path)
                 
-                outputFilePath = path
+                outputFilePath = folderPath
             } else {
                 outputFolderPath.append("/")
                 outputFolderPath.append(outputFileName)