As a user I want the system to suggest date and sender from the filename so I have less to type when uploading scanned documents #69

Closed
opened 2026-03-25 14:12:14 +01:00 by marcel · 1 comment
Owner

Background

Scanners and scanning apps often produce files with structured names like 2024-03-15_Hans_Mueller.pdf or 19650312-Oma.pdf. Parsing these automatically saves several keystrokes per document and reduces the chance of data entry errors.

User Journey

User uploads a file named 1965-03-12_Hans_Mueller.pdf. The system parses the filename and:

  • pre-fills the date field with 12.03.1965
  • pre-fills the sender typeahead with Hans Mueller (shown as a suggestion, not yet committed)

The user can accept, correct, or ignore each suggestion. If the filename doesn't match any known pattern, no suggestion is made and the form behaves as normal.

Parsing patterns to support

Filename pattern Extracted
2024-03-15_Firstname_Lastname.pdf date=2024-03-15, name=Firstname Lastname
20240315_Firstname_Lastname.pdf date=2024-03-15, name=Firstname Lastname
Firstname_Lastname_2024-03-15.pdf date=2024-03-15, name=Firstname Lastname
2024-03-15.pdf date only
Firstname_Lastname.pdf name only

Names are matched loosely — the suggestion is shown in the typeahead but the user must confirm (select from the dropdown or create new person). No automatic person creation from a filename.

E2E Scenarios

Scenario: Date extracted from filename
  Given I am on the new document page
  When I select a file named "1965-03-12_Hans_Mueller.pdf"
  Then the date field shows "12.03.1965"

Scenario: Name extracted as sender suggestion
  Given I am on the new document page
  When I select a file named "1965-03-12_Hans_Mueller.pdf"
  Then the sender typeahead shows "Hans Mueller" as a pre-filled suggestion

Scenario: Unstructured filename produces no suggestion
  Given I am on the new document page
  When I select a file named "scan_001.pdf"
  Then the date field is empty
  And the sender field is empty

Scenario: Manual title not overwritten by parsed name
  Given I have typed a title manually
  When I select a file with a parseable name
  Then the title field is unchanged

Implementation notes

  • Parsing is purely client-side (no backend changes needed).
  • A small parseFilename(name: string): { date?: string; personName?: string } utility function in src/lib/utils/ keeps this testable in isolation.
  • The sender typeahead component already accepts an initialName prop — use that to pass the parsed name.
  • If both drop zone (issue #X) and this feature are active, filename parsing should also run during bulk upload so documents land with dates/names pre-filled where possible.
## Background Scanners and scanning apps often produce files with structured names like `2024-03-15_Hans_Mueller.pdf` or `19650312-Oma.pdf`. Parsing these automatically saves several keystrokes per document and reduces the chance of data entry errors. ## User Journey User uploads a file named `1965-03-12_Hans_Mueller.pdf`. The system parses the filename and: - pre-fills the **date** field with `12.03.1965` - pre-fills the **sender** typeahead with `Hans Mueller` (shown as a suggestion, not yet committed) The user can accept, correct, or ignore each suggestion. If the filename doesn't match any known pattern, no suggestion is made and the form behaves as normal. ## Parsing patterns to support | Filename pattern | Extracted | |---|---| | `2024-03-15_Firstname_Lastname.pdf` | date=2024-03-15, name=Firstname Lastname | | `20240315_Firstname_Lastname.pdf` | date=2024-03-15, name=Firstname Lastname | | `Firstname_Lastname_2024-03-15.pdf` | date=2024-03-15, name=Firstname Lastname | | `2024-03-15.pdf` | date only | | `Firstname_Lastname.pdf` | name only | Names are matched loosely — the suggestion is shown in the typeahead but the user must confirm (select from the dropdown or create new person). No automatic person creation from a filename. ## E2E Scenarios ``` Scenario: Date extracted from filename Given I am on the new document page When I select a file named "1965-03-12_Hans_Mueller.pdf" Then the date field shows "12.03.1965" Scenario: Name extracted as sender suggestion Given I am on the new document page When I select a file named "1965-03-12_Hans_Mueller.pdf" Then the sender typeahead shows "Hans Mueller" as a pre-filled suggestion Scenario: Unstructured filename produces no suggestion Given I am on the new document page When I select a file named "scan_001.pdf" Then the date field is empty And the sender field is empty Scenario: Manual title not overwritten by parsed name Given I have typed a title manually When I select a file with a parseable name Then the title field is unchanged ``` ## Implementation notes - Parsing is purely client-side (no backend changes needed). - A small `parseFilename(name: string): { date?: string; personName?: string }` utility function in `src/lib/utils/` keeps this testable in isolation. - The sender typeahead component already accepts an `initialName` prop — use that to pass the parsed name. - If both drop zone (issue #X) and this feature are active, filename parsing should also run during bulk upload so documents land with dates/names pre-filled where possible.
Author
Owner

Also applies during bulk upload (#66): filename parsing should run for each file in the drop zone, so documents land with dates/names already populated where the filename is structured.

Also applies during bulk upload (#66): filename parsing should run for each file in the drop zone, so documents land with dates/names already populated where the filename is structured.
marcel added the file-upload label 2026-03-25 14:14:31 +01:00
Sign in to join this conversation.
No Label file-upload
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: marcel/familienarchiv#69