             continue
         } else if arg.hasPrefix("-") {
             // Short argument names
-            let flag = arg.substring(from: arg.characters.index(arg.startIndex, offsetBy: 1))
+            let flag = String(arg[arg.index(arg.startIndex, offsetBy: 1)])
             let matches = names.filter { $0.hasPrefix(flag) }
             if matches.count > 1 {
                 print("error: ambiguous argument: \(arg).")

                var filesWritten = 0
                for url in files {
                    let inputDirectory = inputURL.path
                    let path = outputURL.path + url.path.substring(from: inputDirectory.characters.endIndex)
                    let outputDirectory = path.components(separatedBy: "/").dropLast().joined(separator: "/")
                    if (try? manager.createDirectory(atPath: outputDirectory, withIntermediateDirectories: true, attributes: nil)) != nil {
                        filesWritten += processInput(url, andWriteToOutput: URL(fileURLWithPath: path))

    for arg in args {
        if arg.hasPrefix("--") {
            // Long argument names
            let key = String(arg[arg.index(arg.startIndex, offsetBy: 2)...])
            if !names.contains(key) {
                print("error: unknown argument: \(arg).")
                return nil
