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:
10
README.md
10
README.md
@@ -56,18 +56,18 @@ Parses the flat exported filenames and copies them into an organized structure:
|
|||||||
|
|
||||||
```
|
```
|
||||||
output/
|
output/
|
||||||
01069_ABRAHAM, REBEKAH L./
|
ABRAHAM, REBEKAH L./
|
||||||
Tax Documents/
|
Tax Documents/
|
||||||
2025/
|
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/
|
Billing & Invoices/
|
||||||
2026/
|
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/
|
UltraTax CS/
|
||||||
12-31-2008/
|
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/
|
Permanent File/
|
||||||
01069_ABRAHAM, REBEKAH L._Permanent File_02-24-2018_Driver's License.pdf
|
Driver's License.pdf
|
||||||
_unparsed/
|
_unparsed/
|
||||||
(files that couldn't be parsed go here for manual review)
|
(files that couldn't be parsed go here for manual review)
|
||||||
```
|
```
|
||||||
|
|||||||
@@ -133,23 +133,25 @@ def main():
|
|||||||
drawer_id, client_name, folder_parts, date, doc_name = result
|
drawer_id, client_name, folder_parts, date, doc_name = result
|
||||||
dest_dir = os.path.join(
|
dest_dir = os.path.join(
|
||||||
output_dir,
|
output_dir,
|
||||||
f"{drawer_id}_{client_name}",
|
client_name,
|
||||||
*folder_parts,
|
*folder_parts,
|
||||||
)
|
)
|
||||||
success += 1
|
success += 1
|
||||||
|
|
||||||
os.makedirs(dest_dir, exist_ok=True)
|
os.makedirs(dest_dir, exist_ok=True)
|
||||||
src = os.path.join(export_dir, filename)
|
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
|
# Handle duplicate filenames
|
||||||
if os.path.exists(dst):
|
if os.path.exists(dst):
|
||||||
base, fext = os.path.splitext(filename)
|
base, fext = os.path.splitext(dest_filename)
|
||||||
counter = 1
|
counter = 1
|
||||||
while os.path.exists(dst):
|
while os.path.exists(dst):
|
||||||
dst = os.path.join(dest_dir, f"{base}_{counter}{fext}")
|
dst = os.path.join(dest_dir, f"{base}_{counter}{fext}")
|
||||||
counter += 1
|
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)
|
shutil.copy2(src, dst)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user