Let the naming scheme organize files into subfolders

- rename::rename_one now resolves new_name relative to the source file's
  own directory, allowing / as a subdirectory separator (e.g. a naming
  scheme like {show name}/{episode name}) instead of rejecting it. Missing
  intermediate directories are created automatically via create_dir_all.
- New validate_relative_target() replaces the old is_plain_filename():
  still rejects anything that could escape the source directory (empty
  path segments - which also catches a leading-slash absolute path -
  and . / .. segments) plus backslashes (Renamr always treats / as the
  scheme's folder separator regardless of OS), but now allows a
  legitimate multi-segment relative path through.
- The "Unchanged" check now compares the full resolved target path to the
  source, not just the filename, since a computed name can now include
  directory components.
- 6 new tests: organizing into a new subfolder, nested subfolders that
  don't exist yet, conflict detection still works for organized targets,
  and rejection of backslashes / doubled / leading / trailing slashes.
- Frontend: naming-scheme editor hint explains the / convention, and the
  rename confirmation modal notes when a plan will create new subfolders.
- No changes needed in the naming-expression engine itself - it already
  treats / between two {} scriptlets as ordinary literal text.
This commit is contained in:
Renamr Scaffold
2026-08-29 03:36:06 +00:00
parent 855f9bea24
commit 658a235e05
3 changed files with 210 additions and 50 deletions
+7
View File
@@ -810,6 +810,11 @@ export default function RenamePanel() {
set in <strong>TMDB Settings</strong> first. FileBot's own short field names (<code>{"{n}"}</code>,{" "}
<code>{"{s00e00}"}</code>, <code>{"{t}"}</code>, etc.) still work too, side by side with the names above.
</p>
<p className="format-hint">
Use <code>{"/"}</code> in the scheme to organize files into subfolders as part of renaming, e.g.{" "}
<code>{"{show name}/{episode name}"}</code> puts each show in its own folder. Missing folders are created
automatically; nothing outside the file's own folder tree is ever touched.
</p>
</div>
)}
@@ -824,6 +829,8 @@ export default function RenamePanel() {
There's no undo yet — review the list below before continuing.
{renamePlanSkipped > 0 &&
` (${renamePlanSkipped} other file${renamePlanSkipped === 1 ? "" : "s"} excluded: no valid preview.)`}
{renamePlan.some((p) => p.newName.includes("/")) &&
" Some of these also move the file into a new subfolder — any missing folders are created automatically."}
</p>
<div className="modal-plan-list">
{renamePlan.map((p) => (