From 3db00ca7ef4f9a703377bdde156c705d2a95426d Mon Sep 17 00:00:00 2001 From: Broque Thomas <26755000+Nezreka@users.noreply.github.com> Date: Tue, 14 Apr 2026 17:42:54 -0700 Subject: [PATCH] Allow flat single path templates with no subfolder Singles could not be saved as a flat file (e.g. "$artist - $title") because the frontend blocked any template without a "/" and the backend path builder treated an empty folder_path as falsy, falling through to the hardcoded nested-folder structure. Frontend: removed the must-include-slash validation for single templates only (album templates still require it). Backend: changed condition from `if folder_path and filename_base` to `if filename_base` so an empty folder_path is handled correctly as a flat drop into the transfer root. --- web_server.py | 11 ++++++++--- webui/static/script.js | 4 +--- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/web_server.py b/web_server.py index 14a48612..b126a3f6 100644 --- a/web_server.py +++ b/web_server.py @@ -17424,9 +17424,14 @@ def _build_final_path_for_track(context, spotify_artist, album_info, file_ext): } folder_path, filename_base = _get_file_path_from_template(template_context, 'single_path') - if folder_path and filename_base: - final_path = os.path.join(transfer_dir, folder_path, filename_base + file_ext) - os.makedirs(os.path.join(transfer_dir, folder_path), exist_ok=True) + if filename_base: + # folder_path may be '' for flat templates like "$artist - $title" (no subfolders) + if folder_path: + final_path = os.path.join(transfer_dir, folder_path, filename_base + file_ext) + os.makedirs(os.path.join(transfer_dir, folder_path), exist_ok=True) + else: + final_path = os.path.join(transfer_dir, filename_base + file_ext) + os.makedirs(transfer_dir, exist_ok=True) return final_path, True else: # Fallback diff --git a/webui/static/script.js b/webui/static/script.js index b3e71b91..ba0638fb 100644 --- a/webui/static/script.js +++ b/webui/static/script.js @@ -5562,9 +5562,7 @@ function validateFileOrganizationTemplates() { if (singlePath.startsWith('/')) { errors.push('Single template cannot start with /'); } - if (!singlePath.includes('/')) { - errors.push('Single template must include at least one folder (use / separator)'); - } + // Note: single template is allowed to have no slash (flat file: "$artist - $title") if (singlePath.includes('//')) { errors.push('Single template cannot have consecutive slashes //'); }