updated the organizer logic so that unparased files at least still get put in the correct client folder
This commit is contained in:
@@ -229,19 +229,30 @@ def exported_doc_name(filename):
|
||||
return stem[anchors[-1].end():]
|
||||
|
||||
|
||||
def client_name_from_files(files):
|
||||
"""Best-effort client name from a drawer's export filenames, or None.
|
||||
def client_name_from_filename(filename):
|
||||
"""Best-effort client name from a single export filename, or None.
|
||||
|
||||
Filenames are '{drawer}_{client}_{folder}_{MM-DD-YYYY}_{doc}.ext', so the
|
||||
client name is the second underscore-delimited token. Client names carry
|
||||
commas/spaces but not underscores; the most common value across the drawer's
|
||||
files is returned to shrug off any oddball filename.
|
||||
commas/spaces but not underscores, so this token is reliable even when the
|
||||
fuller parse (folder/date matching) fails.
|
||||
"""
|
||||
parts = filename.split("_")
|
||||
if len(parts) >= 2 and parts[1].strip():
|
||||
return parts[1].strip()
|
||||
return None
|
||||
|
||||
|
||||
def client_name_from_files(files):
|
||||
"""Best-effort client name from a drawer's export filenames, or None.
|
||||
|
||||
The most common per-file client name is returned to shrug off any oddball
|
||||
filename.
|
||||
"""
|
||||
counts = {}
|
||||
for f in files:
|
||||
parts = f.split("_")
|
||||
if len(parts) >= 2 and parts[1].strip():
|
||||
name = parts[1].strip()
|
||||
name = client_name_from_filename(f)
|
||||
if name:
|
||||
counts[name] = counts.get(name, 0) + 1
|
||||
if not counts:
|
||||
return None
|
||||
|
||||
Reference in New Issue
Block a user