When a user requests invoice organization:
- Scan the Folder
Identify all invoice files:
```bash
# Find all invoice-related files
find . -type f \( -name ".pdf" -o -name ".jpg" -o -name "*.png" \) -print
```
Report findings:
- Total number of files
- File types
- Date range (if discernible from names)
- Current organization (or lack thereof)
- Extract Information from Each File
For each invoice, extract:
From PDF invoices:
- Use text extraction to read invoice content
- Look for common patterns:
- "Invoice Date:", "Date:", "Issued:"
- "Invoice #:", "Invoice Number:"
- Company name (usually at top)
- "Amount Due:", "Total:", "Amount:"
- "Description:", "Service:", "Product:"
From image receipts:
- Read visible text from images
- Identify vendor name (often at top)
- Look for date (common formats)
- Find total amount
Fallback for unclear files:
- Use filename clues
- Check file creation/modification date
- Flag for manual review if critical info missing
- Determine Organization Strategy
Ask user preference if not specified:
```markdown
I found [X] invoices from [date range].
How would you like them organized?
1. By Vendor (Adobe/, Amazon/, Stripe/, etc.)
2. By Category (Software/, Office Supplies/, Travel/, etc.)
3. By Date (2024/Q1/, 2024/Q2/, etc.)
4. By Tax Category (Deductible/, Personal/, etc.)
5. Custom (describe your structure)
Or I can use a default structure: Year/Category/Vendor
```
- Create Standardized Filename
For each invoice, create a filename following this pattern:
```
YYYY-MM-DD Vendor - Invoice - Description.ext
```
Examples:
- 2024-03-15 Adobe - Invoice - Creative Cloud.pdf
- 2024-01-10 Amazon - Receipt - Office Supplies.pdf
- 2023-12-01 Stripe - Invoice - Monthly Payment Processing.pdf
Filename Best Practices:
- Remove special characters except hyphens
- Capitalize vendor names properly
- Keep descriptions concise but meaningful
- Use consistent date format (YYYY-MM-DD) for sorting
- Preserve original file extension
- Execute Organization
Before moving files, show the plan:
```markdown
# Organization Plan
## Proposed Structure
```
Invoices/
βββ 2023/
β βββ Software/
β β βββ Adobe/
β β βββ Microsoft/
β βββ Services/
β βββ Office/
βββ 2024/
βββ Software/
βββ Services/
βββ Office/
```
## Sample Changes
Before: invoice_adobe_march.pdf
After: 2024-03-15 Adobe - Invoice - Creative Cloud.pdf
Location: Invoices/2024/Software/Adobe/
Before: IMG_2847.jpg
After: 2024-02-10 Staples - Receipt - Office Supplies.jpg
Location: Invoices/2024/Office/Staples/
Process [X] files? (yes/no)
```
After approval:
```bash
# Create folder structure
mkdir -p "Invoices/2024/Software/Adobe"
# Copy (don't move) to preserve originals
cp "original.pdf" "Invoices/2024/Software/Adobe/2024-03-15 Adobe - Invoice - Creative Cloud.pdf"
# Or move if user prefers
mv "original.pdf" "new/path/standardized-name.pdf"
```
- Generate Summary Report
Create a CSV file with all invoice details:
```csv
Date,Vendor,Invoice Number,Description,Amount,Category,File Path
2024-03-15,Adobe,INV-12345,Creative Cloud,52.99,Software,Invoices/2024/Software/Adobe/2024-03-15 Adobe - Invoice - Creative Cloud.pdf
2024-03-10,Amazon,123-4567890-1234567,Office Supplies,127.45,Office,Invoices/2024/Office/Amazon/2024-03-10 Amazon - Receipt - Office Supplies.pdf
...
```
This CSV is useful for:
- Importing into accounting software
- Sharing with accountants
- Expense tracking and reporting
- Tax preparation
- Provide Completion Summary
```markdown
# Organization Complete! π
## Summary
- Processed: [X] invoices
- Date range: [earliest] to [latest]
- Total amount: $[sum] (if amounts extracted)
- Vendors: [Y] unique vendors
## New Structure
```
Invoices/
βββ 2024/ (45 files)
β βββ Software/ (23 files)
β βββ Services/ (12 files)
β βββ Office/ (10 files)
βββ 2023/ (12 files)
```
## Files Created
- /Invoices/ - Organized invoices
- /Invoices/invoice-summary.csv - Spreadsheet for accounting
- /Invoices/originals/ - Original files (if copied)
## Files Needing Review
[List any files where information couldn't be extracted completely]
## Next Steps
1. Review the invoice-summary.csv file
2. Check files in "Needs Review" folder
3. Import CSV into your accounting software
4. Set up auto-organization for future invoices
Ready for tax season! π
```