tweaked reorganize so it only puts client names (drops ID) and the original filename instead of the full name that FCCS exports

This commit is contained in:
2026-07-06 16:48:10 -05:00
parent 2d679e2497
commit 2b9d1bda12
2 changed files with 11 additions and 9 deletions

View File

@@ -56,18 +56,18 @@ Parses the flat exported filenames and copies them into an organized structure:
```
output/
01069_ABRAHAM, REBEKAH L./
ABRAHAM, REBEKAH L./
Tax Documents/
2025/
01069_ABRAHAM, REBEKAH L._2025 Tax Documents_03-03-2026_030126 E-mail re Tax Info.pdf
030126 E-mail re Tax Info.pdf
Billing & Invoices/
2026/
01069_ABRAHAM, REBEKAH L._2026 Billing & Invoices_030826 Invoice for 2025 Forms 1040...pdf
030826 Invoice for 2025 Forms 1040 & IL-1040.pdf
UltraTax CS/
12-31-2008/
01069_ABRAHAM, REBEKAH L._UltraTax CS 12-31-2008_02-12-2009_2008 Form 1040 Filing Instructions.doc
2008 Form 1040 Filing Instructions.doc
Permanent File/
01069_ABRAHAM, REBEKAH L._Permanent File_02-24-2018_Driver's License.pdf
Driver's License.pdf
_unparsed/
(files that couldn't be parsed go here for manual review)
```

View File

@@ -133,23 +133,25 @@ def main():
drawer_id, client_name, folder_parts, date, doc_name = result
dest_dir = os.path.join(
output_dir,
f"{drawer_id}_{client_name}",
client_name,
*folder_parts,
)
success += 1
os.makedirs(dest_dir, exist_ok=True)
src = os.path.join(export_dir, filename)
dst = os.path.join(dest_dir, filename)
# For parsed files, use just the document name; for unparsed, keep original
dest_filename = doc_name if result else filename
dst = os.path.join(dest_dir, dest_filename)
# Handle duplicate filenames
if os.path.exists(dst):
base, fext = os.path.splitext(filename)
base, fext = os.path.splitext(dest_filename)
counter = 1
while os.path.exists(dst):
dst = os.path.join(dest_dir, f"{base}_{counter}{fext}")
counter += 1
log(f" DUPLICATE renamed: {filename} -> {os.path.basename(dst)}")
log(f" DUPLICATE renamed: {dest_filename} -> {os.path.basename(dst)}")
shutil.copy2(src, dst)