             if let validPath = validPath {
                 url = url.appendingPathComponent(validPath, isDirectory: false)
             }
-            if url.absoluteString.lowercased().prefix(filePrefix.characters.count) != filePrefix {
+            if url.absoluteString.lowercased().prefix(filePrefix.count) != filePrefix {
                 let fixedUrl = filePrefix + url.absoluteString
                 url = URL(string: fixedUrl)!
             }

        let fileExtension = url.pathExtension
        let filePath = url.lastPathComponent
        let fileName = filePath.replacingOccurrences(of: fileExtension, with: "")
        return Int(String(fileName.characters.filter { "0123456789".characters.contains($0) }))
    }
}

            if let validPath = validPath {
                temporaryUrl = temporaryUrl.appendingPathComponent(validPath, isDirectory: false)
            }
            if temporaryUrl.absoluteString.lowercased().prefix(filePrefix.count) != filePrefix {
                let fixedUrl = filePrefix + temporaryUrl.absoluteString
                temporaryUrl = URL(string: fixedUrl)!
            }
