{"record":{"id":"9b4fdeef82537aae","repo":"Tyrrrz/DiscordChatExporter","slug":"attempted-to-export-multiple-channels-but-the-out","errorCode":null,"errorMessage":"Attempted to export multiple channels, but the output path is neither a directory nor a template. If the provided output path is meant to be treated as a directory, make sure it ends with a slash. Provided output path: '{OutputPath}'.","messagePattern":"Attempted to export multiple channels, but the output path is neither a directory nor a template\\. If the provided output path is meant to be treated as a directory, make sure it ends with a slash\\. Provided output path: '(.+?)'\\.","errorType":"validation","errorClass":"CommandException","httpStatus":null,"severity":"error","filePath":"DiscordChatExporter.Cli/Commands/Base/ExportCommandBase.cs","lineNumber":192,"sourceCode":"        // https://github.com/Tyrrrz/DiscordChatExporter/issues/1549\n        var mayExportMultipleChannels =\n            // Multiple channels were provided explicitly\n            channels.Count > 1\n            // Thread inclusion can add more channels to the export\n            || ThreadInclusionMode != ThreadInclusionMode.None;\n\n        var isValidOutputPath =\n            // Anything is valid when exporting a single channel\n            !mayExportMultipleChannels\n            // When using template tokens, assume the user knows what they're doing\n            || OutputPath.Contains('%')\n            // Otherwise, require an existing directory or an unambiguous directory path\n            || Directory.Exists(OutputPath)\n            || Path.EndsInDirectorySeparator(OutputPath);\n\n        if (!isValidOutputPath)\n        {\n            throw new CommandException(\n                \"Attempted to export multiple channels, but the output path is neither a directory nor a template. \"\n                    + \"If the provided output path is meant to be treated as a directory, make sure it ends with a slash. \"\n                    + $\"Provided output path: '{OutputPath}'.\"\n            );\n        }\n\n        var unwrappedChannels = new List<Channel>(channels);\n\n        // Unwrap threads\n        if (ThreadInclusionMode != ThreadInclusionMode.None)\n        {\n            await console.Output.WriteLineAsync(\"Fetching threads...\");\n\n            var fetchedThreadsCount = 0;\n            await console\n                .CreateStatusTicker()\n                .StartAsync(\n                    \"...\",","sourceCodeStart":174,"sourceCodeEnd":210,"githubUrl":"https://github.com/Tyrrrz/DiscordChatExporter/blob/f6865c82167c3bfee4455da80a1f1ca5e71b95ad/DiscordChatExporter.Cli/Commands/Base/ExportCommandBase.cs#L174-L210","documentation":"Thrown as a CommandException when exporting multiple channels but the resolved output path is neither an existing directory, a path ending in a directory separator, nor a template containing a `%` token. DiscordChatExporter refuses to overwrite a single file with multiple channels' worth of output. The check runs early (before thread fetching) so the user fails fast.","triggerScenarios":"Calling exportall/exportguild with more than one resolved channel AND an OutputPath that fails all four conditions in ExportCommandBase.cs:184-189: not a single channel, no `%`, Directory.Exists is false, and Path.EndsInDirectorySeparator is false. Example: `exportall -g <id> -o out.html`.","commonSituations":"Pointing -o at a filename like `dump.html` when exporting a guild; forgetting the trailing slash on a relative directory; running on a fresh checkout where the target directory has not been created yet.","solutions":["Add a trailing path separator to mark the output as a directory: `-o ./exports/`.","Use template tokens so each channel gets a distinct file: `-o ./exports/%g-%c.html`.","Pre-create the directory and pass it (e.g. `mkdir -p exports && -o ./exports`).","If you really meant a single channel, switch to exportchat with one channel ID."],"exampleFix":"// before\ndotnet run -- exportall -g <guild> -t <token> -o out.html\n// after\ndotnet run -- exportall -g <guild> -t <token> -o \"./exports/%g-%c.html\"","handlingStrategy":"validation","validationCode":"bool isDir = Directory.Exists(options.OutputPath) || Path.EndsInDirectorySeparator(options.OutputPath);\nbool isTemplate = options.OutputPath.Contains('%');\nbool multiple = channelIds.Count > 1;\nif (multiple && !isDir && !isTemplate)\n    throw new ArgumentException(\"Output path must be a directory (trailing slash) or a % template for multi-channel export.\");","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always end multi-channel output paths with a path separator or include a % token.","Standardize on a template like '%g-%c' for batch exports.","Pre-create the output directory before running the command."],"tags":["cli","options","output-path","multi-channel"],"backgroundTag":null,"analyzedSha":"f6865c82167c3bfee4455da80a1f1ca5e71b95ad","analyzedAt":"2026-08-13T18:08:46.403Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}