updated the reorganize script to handle nested folders inside of template files like 'YYYY' Income Documents > 2016 > Joe Shmo 2016

This commit is contained in:
2026-08-24 21:43:43 -05:00
parent 253e4fe419
commit 5e7630bf5c
3 changed files with 32 additions and 7 deletions

View File

@@ -26,6 +26,8 @@ from fccs_config import parse_args, load_config
_DATE_RE = re.compile(r"_(\d{2}-\d{2}-\d{4})_")
# A standalone year inside a folder name, e.g. "2013 Tax Documents".
_YEAR_RE = re.compile(r"\b(19|20)\d{2}\b")
# Trailing "[Subfolder]" group(s) — FCCS's encoding for nested subfolders.
_SUBFOLDER_RE = re.compile(r"(?:\[[^\[\]]+\])+$")
UNPARSED_DIRNAME = "_unparsed"
@@ -55,8 +57,13 @@ def suggest_template(folder_field):
"""Generalize a concrete folder field into an fccs_folders.txt line.
e.g. "2013 Tax Documents" -> "YYYY Tax Documents". Fields without a year
are suggested as-is (static folders).
are suggested as-is (static folders). Trailing [Subfolder] groups (FCCS's
nested-subfolder encoding) are dropped so the suggestion is the parent
template line, which is what fccs_folders.txt actually takes.
"""
stripped = _SUBFOLDER_RE.sub("", folder_field).strip()
if stripped:
folder_field = stripped
return _YEAR_RE.sub("YYYY", folder_field)