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

@@ -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)