JosefNemec/Playnite · error · Exception

Theme directory "{outDir}" already exists.

Error message

Theme directory "{outDir}" already exists.

What it means

Thrown by Themes.GenerateNewTheme when the computed output directory already exists. outDir = ThemesProgramPath/<mode>/<safeThemeName>; Toolbox refuses to overwrite an existing theme folder to avoid clobbering prior work. The check is `Directory.Exists(outDir)` before any file is written.

Source

Thrown at source/Tools/Playnite.Toolbox/Themes.cs:464

            {
                foreach (var fontFile in Directory.GetFiles(modeFontDir))
                {
                    var targetPath = Path.Combine(outDir, "Fonts", Path.GetFileName(fontFile));
                    FileSystem.CopyFile(fontFile, targetPath);
                }
            }

            return defaultThemeXamlFiles;
        }

        public static string GenerateNewTheme(ApplicationMode mode, string themeName)
        {
            var themeDirName = Common.Paths.GetSafePathName(themeName).Replace(" ", string.Empty);
            var defaultThemeDir = Path.Combine(Paths.GetThemesPath(mode), "Default");
            var outDir = Path.Combine(PlaynitePaths.ThemesProgramPath, mode.GetDescription(), themeDirName);
            if (Directory.Exists(outDir))
            {
                throw new Exception($"Theme directory \"{outDir}\" already exists.");
            }

            FileSystem.CreateDirectory(outDir);
            var defaultThemeXamlFiles = GenerateCommonThemeFiles(mode, outDir);
            CopyThemeDirectory(defaultThemeDir, outDir, defaultThemeXamlFiles.Select(a => Path.Combine(defaultThemeDir, a)).ToList());

            var themeDesc = new ThemeManifest()
            {
                Id = themeName + "_" + Guid.NewGuid().ToString(),
                Author = "Your Name Here",
                Name = themeName,
                Version = "1.0",
                Mode = mode,
                ThemeApiVersion = ThemeManager.GetApiVersion(mode).ToString()
            };

            File.WriteAllText(Path.Combine(outDir, PlaynitePaths.ThemeManifestFileName), Serialization.ToYaml(themeDesc));
            Explorer.NavigateToFileSystemEntry(Path.Combine(outDir, PlaynitePaths.ThemeSlnFileName));

View on GitHub (pinned to 5911f4e964)

Solutions

  1. Pick a different theme name that does not collide with an existing folder.
  2. Delete or rename the existing outDir before regenerating.
  3. Check Directory.Exists for the computed path first; note GetSafePathName strips spaces, so the on-disk name may differ from your input.
  4. Back up the existing theme folder, remove it, then re-run `new`.

Example fix

// before
//   Toolbox new DesktopTheme My Theme   # 'MyTheme' folder exists

// after
//   either: rename the existing Themes/.../MyTheme folder
//   or:     Toolbox new DesktopTheme MyThemeV2
Defensive patterns

Strategy: validation

Validate before calling

if (Directory.Exists(outDir))
    throw new InvalidOperationException($"Theme directory already exists: {outDir}");

Prevention

When it happens

Trigger: Running `Toolbox new DesktopTheme MyTheme` (or FullscreenTheme) when a folder of the same safe name already exists under the program themes path for that mode.

Common situations: Re-running `new` after a partial/aborted generation; choosing a theme name that collides with the Default or a previously created theme; spaces/uppercase normalized away by GetSafePathName causing an unexpected collision.

Related errors


AI-assisted analysis of JosefNemec/Playnite@5911f4e964 (2026-08-13). Data as JSON: /api/errors/e0a012145c49af09. Report an issue: GitHub.