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