updated the organizer logic so that unparased files at least still get put in the correct client folder
This commit is contained in:
@@ -13,11 +13,14 @@ Examples:
|
||||
01069_ABRAHAM, REBEKAH L._UltraTax CS 12-31-2008_02-12-2009_2008 Form 1040 Filing Instructions.doc
|
||||
|
||||
Output structure (recreates FCCS UI nesting):
|
||||
output/{drawer_id}_{client_name}/Tax Documents/2025/{original_filename}
|
||||
output/{drawer_id}_{client_name}/UltraTax CS/12-31-2008/{original_filename}
|
||||
output/{drawer_id}_{client_name}/Permanent File/{original_filename}
|
||||
output/{client_name}/Tax Documents/2025/{original_filename}
|
||||
output/{client_name}/UltraTax CS/12-31-2008/{original_filename}
|
||||
output/{client_name}/Permanent File/{original_filename}
|
||||
|
||||
Files that cannot be parsed go to output/_unparsed/ for manual review.
|
||||
Files that cannot be parsed are still filed under their client:
|
||||
output/{client_name}/_unparsed/{original_filename}
|
||||
Only files whose client can't be recovered from the leading tokens fall back to
|
||||
the top-level output/_unparsed/ for manual review.
|
||||
"""
|
||||
|
||||
import os
|
||||
@@ -28,6 +31,7 @@ import sys
|
||||
from fccs_config import (
|
||||
parse_args, load_config, make_logger,
|
||||
load_folder_list, build_folder_patterns, decompose_folder_path,
|
||||
client_name_from_filename,
|
||||
)
|
||||
|
||||
# Regex for the creation date field (MM-DD-YYYY) bounded by underscores
|
||||
@@ -126,8 +130,17 @@ def main():
|
||||
result = parse_filename(filename, folder_patterns)
|
||||
|
||||
if result is None:
|
||||
log(f" UNPARSED: {filename}")
|
||||
dest_dir = os.path.join(output_dir, "_unparsed")
|
||||
# Still recover the client from the leading tokens so the file lands
|
||||
# in that client's folder (in an _unparsed subfolder to flag it),
|
||||
# rather than a single top-level bucket. Fall back to the top-level
|
||||
# _unparsed only when even the client can't be determined.
|
||||
client_name = client_name_from_filename(filename)
|
||||
if client_name:
|
||||
dest_dir = os.path.join(output_dir, client_name, "_unparsed")
|
||||
log(f" UNPARSED (filed under {client_name}): {filename}")
|
||||
else:
|
||||
dest_dir = os.path.join(output_dir, "_unparsed")
|
||||
log(f" UNPARSED (no client): {filename}")
|
||||
failed += 1
|
||||
else:
|
||||
drawer_id, client_name, folder_parts, date, doc_name = result
|
||||
@@ -158,7 +171,9 @@ def main():
|
||||
log("=" * 60)
|
||||
log(f"Reorganization complete: {success} organized, {failed} unparsed")
|
||||
if failed:
|
||||
log(f"Review unparsed files in: {os.path.join(output_dir, '_unparsed')}")
|
||||
log("Review unparsed files in each client's _unparsed subfolder "
|
||||
f"(and {os.path.join(output_dir, '_unparsed')} for any without a "
|
||||
"detectable client).")
|
||||
log("=" * 60)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user