A CLI tool to bulk rename YNAB payees that match a specific pattern
Project description
YNAB Bulk Rename
A command-line tool to bulk rename YNAB (You Need A Budget) payees that match a specific pattern.
Description
This CLI tool finds payees that match a regex pattern and renames them by removing the matched pattern. By default, it targets payees starting with "CARTE DD/MM " (where DD/MM is a date) and removes this prefix, but you can customize the pattern for your needs.
Installation
Install from PyPI:
pip install ynab-bulk-rename
Or install from source:
pip install -e .
Setup
- Get your YNAB API token:
- Go to https://app.ynab.com/settings/developer
- Generate a new Personal Access Token
- Set it as an environment variable (see below)
Usage
Basic Commands
# Set your YNAB token (required)
export YNAB_TOKEN='your_actual_token_here'
# Dry run with default pattern (shows what would be changed)
ynab-bulk-rename your_budget_id
# Actually perform the rename operations
ynab-bulk-rename your_budget_id --no-dry-run
# Use a custom pattern
ynab-bulk-rename your_budget_id --pattern "^PAYMENT \d{2}/\d{2} "
# Custom pattern with actual rename
ynab-bulk-rename your_budget_id --pattern "^MERCHANT_PREFIX " --no-dry-run
Command Line Arguments
positional arguments:
budget_id YNAB budget ID to work with
optional arguments:
-h, --help show this help message and exit
--pattern PATTERN, -p PATTERN
Regex pattern to match payees (default: '^CARTE \d{2}/\d{2} ')
--no-dry-run Actually perform the rename operations (default: dry run only)
--skip-pause Skip the pause between API calls (default: pause when ≥199 payees)
--version show program's version number and exit
Examples
# Example 1: Default pattern (dry run)
ynab-bulk-rename fedd1ee2-8048-4e69-95e5-cf2cab422dc5
# Example 2: Actually rename with default pattern
ynab-bulk-rename fedd1ee2-8048-4e69-95e5-cf2cab422dc5 --no-dry-run
# Example 3: Custom pattern for different card format
ynab-bulk-rename fedd1ee2-8048-4e69-95e5-cf2cab422dc5 --pattern "^CARD \d{4} "
# Example 4: Remove merchant prefixes
ynab-bulk-rename fedd1ee2-8048-4e69-95e5-cf2cab422dc5 --pattern "^MERCHANT " --no-dry-run
# Example 5: Skip pauses for faster processing (use with caution)
ynab-bulk-rename fedd1ee2-8048-4e69-95e5-cf2cab422dc5 --no-dry-run --skip-pause
# Example 6: One-time usage with environment variable
YNAB_TOKEN='your_token' ynab-bulk-rename your_budget_id --no-dry-run
Environment Variables
- YNAB_TOKEN (required): Your YNAB Personal Access Token
- Get it from: https://app.ynab.com/settings/developer
- Keep it secure - never commit it to version control!
Example Output
Small batch (under rate limit):
🎯 Budget ID: fedd1ee2-8048-4e69-95e5-cf2cab422dc5
🔍 Pattern: ^CARTE \d{2}/\d{2}
🏃 Mode: ACTUAL RENAME
--------------------------------------------------
Fetching payees...
Found 5 payees matching the pattern:
⚡ No pauses needed - 5 payees is under rate limit (199)
- CARTE 15/12 GROCERY STORE -> GROCERY STORE
Successfully renamed payee to: GROCERY STORE
- CARTE 16/12 GAS STATION -> GAS STATION
Successfully renamed payee to: GAS STATION
- CARTE 17/12 RESTAURANT -> RESTAURANT
Successfully renamed payee to: RESTAURANT
✅ Successfully processed 5 payees!
Large batch (with rate limiting):
🎯 Budget ID: fedd1ee2-8048-4e69-95e5-cf2cab422dc5
🔍 Pattern: ^CARTE \d{2}/\d{2}
🏃 Mode: ACTUAL RENAME
--------------------------------------------------
Fetching payees...
Found 200 payees matching the pattern:
⚠️ YNAB API Rate Limit: 200 requests/hour
⏱️ Estimated completion time: ~1h 6m
(20 second pause between each rename to stay within limits)
- CARTE 15/12 GROCERY STORE -> GROCERY STORE
Successfully renamed payee to: GROCERY STORE
⏳ Pausing for 20 seconds... (1/200 completed)
- CARTE 16/12 GAS STATION -> GAS STATION
...
Safety Features
- Dry Run Mode: By default, the tool only shows what would be changed without making actual changes
- Error Handling: Includes proper error handling for API requests and invalid regex patterns
- Pattern Validation: Validates regex patterns before processing
- Intelligent Rate Limiting: Automatically skips pauses when processing <199 payees (within rate limit)
- Manual Pause Control:
--skip-pauseoption to override rate limiting (use with caution) - Graceful Interruption: Can be cancelled safely with Ctrl+C
Performance Notes
⚠️ Rate Limiting: The YNAB API has a rate limit of 200 requests per hour.
Automatic Optimization:
- ≤198 payees: No pauses needed (instant processing)
- ≥199 payees: 20-second pauses between operations
- Manual override:
--skip-pauseskips all pauses (use carefully)
Timing Examples:
- 1-198 payees: Instant (no pauses)
- 199+ payees: ~20 seconds per payee after the first
- Example: 5 payees = instant, 250 payees = ~1 hour 20 minutes
The tool will show the processing strategy before starting operations.
Regex Pattern Examples
^CARTE \d{2}/\d{2}- Matches "CARTE 15/12 STORE" → "STORE"^PAYMENT \d{4}- Matches "PAYMENT 1234 DESC" → "DESC"^MERCHANT- Matches "MERCHANT STORE NAME" → "STORE NAME"^CARD\*\d{4}- Matches "CARD*1234 PURCHASE" → "PURCHASE"
Requirements
- Python 3.10+
- requests library
- Valid YNAB API token
- YNAB budget with payees to rename
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file ynab_bulk_rename-0.1.0.tar.gz.
File metadata
- Download URL: ynab_bulk_rename-0.1.0.tar.gz
- Upload date:
- Size: 13.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3a9dd6f6c68bb5264da08b75704cf96feaa3ccb4046bab2e87a1c34d5a277fdb
|
|
| MD5 |
bcfce946f492fa5748c783abd266aad0
|
|
| BLAKE2b-256 |
c8f3ec78c4f129d6d335c9995a254a1a0218224d7f4b7956a1f8e0a907906605
|
Provenance
The following attestation bundles were made for ynab_bulk_rename-0.1.0.tar.gz:
Publisher:
publish.yml on codingcastor/ynab-bulk-rename
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
ynab_bulk_rename-0.1.0.tar.gz -
Subject digest:
3a9dd6f6c68bb5264da08b75704cf96feaa3ccb4046bab2e87a1c34d5a277fdb - Sigstore transparency entry: 267339745
- Sigstore integration time:
-
Permalink:
codingcastor/ynab-bulk-rename@3a5124fb7c09a04427a8795475f9783bcfff7092 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/codingcastor
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@3a5124fb7c09a04427a8795475f9783bcfff7092 -
Trigger Event:
release
-
Statement type:
File details
Details for the file ynab_bulk_rename-0.1.0-py3-none-any.whl.
File metadata
- Download URL: ynab_bulk_rename-0.1.0-py3-none-any.whl
- Upload date:
- Size: 7.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0cbcf9cc61dcca74d2109ac24d06dca4645dc8c22bfe2f8402296e031cab94e4
|
|
| MD5 |
25f8cf3798d265ac4846c0f6ed2034ad
|
|
| BLAKE2b-256 |
4affa90e8d775baf6a3e767203b08c77017c4f3a4dd7426941ab44e022b1f2fb
|
Provenance
The following attestation bundles were made for ynab_bulk_rename-0.1.0-py3-none-any.whl:
Publisher:
publish.yml on codingcastor/ynab-bulk-rename
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
ynab_bulk_rename-0.1.0-py3-none-any.whl -
Subject digest:
0cbcf9cc61dcca74d2109ac24d06dca4645dc8c22bfe2f8402296e031cab94e4 - Sigstore transparency entry: 267339754
- Sigstore integration time:
-
Permalink:
codingcastor/ynab-bulk-rename@3a5124fb7c09a04427a8795475f9783bcfff7092 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/codingcastor
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@3a5124fb7c09a04427a8795475f9783bcfff7092 -
Trigger Event:
release
-
Statement type: