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:
@@ -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)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user