Configuration
The Audiobook Organizer supports multiple configuration methods: config files, environment variables, and CLI flags. This guide covers all configuration options and their precedence.
Configuration Precedence
Section titled “Configuration Precedence”Configuration values are loaded in this order (later sources override earlier ones):
Defaults → Config File → Environment Variables → CLI Flags(lowest) (highest)Example:
# Config file sets: layout=author-title# Environment sets: AO_LAYOUT=author-series-title# CLI flag sets: --layout=author-only
# Result: author-only (CLI flag wins)Config File
Section titled “Config File”File Locations
Section titled “File Locations”The organizer searches for config files in this order:
- Custom path (if specified):
--config /path/to/config.yaml - Current directory:
./.audiobook-organizer.yaml - Home directory:
~/.audiobook-organizer.yaml
First file found is used. Subsequent files are ignored.
File Format
Section titled “File Format”Config files use YAML format:
# Basic configurationdir: "/path/to/audiobooks"out: "/path/to/organized"
# Organization optionslayout: "author-series-title"layout-template: ""replace_space: ""remove-empty: trueuse-embedded-metadata: falseflat: falseverbose: falsedry-run: falseprompt: false
# Field mappingauthor-fields: "authors,narrators,album_artist,artist"series-field: "series"title-field: "album,title"track-field: "track,track_number"
# Rename options (for rename command)template: "{author} - {series} {series_number} - {title}"author-format: "first-last"recursive: truepreserve-path: truestrict: falseCreating a Config File
Section titled “Creating a Config File”Recommended location: Home directory
# Create config filecat > ~/.audiobook-organizer.yaml <<'EOF'# Audiobook Organizer Configuration
# Default directoriesdir: "/media/audiobooks"out: "/media/organized"
# Organization settingslayout: "author-series-title"use-embedded-metadata: trueremove-empty: trueverbose: true
# Field mapping for MP3 filesauthor-fields: "narrators,authors,album_artist,artist"title-field: "album"EOFAll Configuration Options
Section titled “All Configuration Options”Directory Options
Section titled “Directory Options”| Option | Type | Default | Description |
|---|---|---|---|
dir / input | string | (required) | Input directory containing audiobooks |
out / output | string | Same as dir | Output directory for organized files |
Note: Both dir/input and out/output are interchangeable aliases.
Organization Options
Section titled “Organization Options”| Option | Type | Default | Description |
|---|---|---|---|
layout | string | author-series-title | Directory structure pattern (see LAYOUTS.md) |
layout-template | string | (empty) | Custom directory layout template that overrides layout |
replace_space | string | (empty) | Character to replace spaces in paths |
remove-empty | boolean | false | Remove empty directories after organizing |
use-embedded-metadata | boolean | false | Extract metadata from audio file tags |
flat | boolean | false | Process files individually (auto-enables use-embedded-metadata) |
dry-run | boolean | false | Preview changes without executing |
verbose | boolean | false | Show detailed progress output |
prompt | boolean | false | Review and confirm each book move |
undo | boolean | false | Restore files to original locations |
Field Mapping Options
Section titled “Field Mapping Options”| Option | Type | Default | Description |
|---|---|---|---|
author-fields | string | authors | Comma-separated fields to try for author (priority order) |
series-field | string | series | Field to use for series |
title-field | string | title | Field to use for title |
track-field | string | track | Field to use for track number |
Rename Options
Section titled “Rename Options”| Option | Type | Default | Description |
|---|---|---|---|
template | string | {author} - {series} {series_number} - {title} | Filename template with placeholders |
author-format | string | first-last | Author name format: first-last, last-first, preserve |
recursive | boolean | true | Recursively process subdirectories |
preserve-path | boolean | true | Only rename filename, keep directory structure |
strict | boolean | false | Error on missing template fields |
Other Options
Section titled “Other Options”| Option | Type | Default | Description |
|---|---|---|---|
config | string | ~/.audiobook-organizer.yaml | Path to config file |
Environment Variables
Section titled “Environment Variables”All options can be set via environment variables using either AO_ or AUDIOBOOK_ORGANIZER_ prefix.
Prefix Options
Section titled “Prefix Options”Both prefixes work identically:
- Short:
AO_*(e.g.,AO_VERBOSE) - Long:
AUDIOBOOK_ORGANIZER_*(e.g.,AUDIOBOOK_ORGANIZER_VERBOSE)
Choose based on your preference. Short prefix is more concise.
Variable Names
Section titled “Variable Names”Environment variable names are uppercase with underscores. Hyphens in config options become underscores.
Config option → Environment variable:
dir→AO_DIRorAUDIOBOOK_ORGANIZER_DIRuse-embedded-metadata→AO_USE_EMBEDDED_METADATAremove-empty→AO_REMOVE_EMPTY
Complete Environment Variable Reference
Section titled “Complete Environment Variable Reference”Directory Variables
Section titled “Directory Variables”# Input directory (all are equivalent)export AO_DIR="/path/to/audiobooks"export AO_INPUT="/path/to/audiobooks"export AUDIOBOOK_ORGANIZER_DIR="/path/to/audiobooks"export AUDIOBOOK_ORGANIZER_INPUT="/path/to/audiobooks"
# Output directory (all are equivalent)export AO_OUT="/path/to/output"export AO_OUTPUT="/path/to/output"export AUDIOBOOK_ORGANIZER_OUT="/path/to/output"export AUDIOBOOK_ORGANIZER_OUTPUT="/path/to/output"Organization Variables (Short Prefix)
Section titled “Organization Variables (Short Prefix)”export AO_LAYOUT="author-series-title"export AO_LAYOUT_TEMPLATE="{author}/{series}/{series-count} - {title}"export AO_REPLACE_SPACE="_"export AO_REMOVE_EMPTY=trueexport AO_USE_EMBEDDED_METADATA=trueexport AO_FLAT=falseexport AO_DRY_RUN=falseexport AO_VERBOSE=trueexport AO_PROMPT=falseField Mapping Variables (Short Prefix)
Section titled “Field Mapping Variables (Short Prefix)”export AO_AUTHOR_FIELDS="authors,narrators,album_artist,artist"export AO_SERIES_FIELD="series"export AO_TITLE_FIELD="album,title"export AO_TRACK_FIELD="track,track_number"Rename Variables (Short Prefix)
Section titled “Rename Variables (Short Prefix)”export AO_TEMPLATE="{author} - {series} {series_number} - {title}"export AO_AUTHOR_FORMAT="first-last"export AO_RECURSIVE=trueexport AO_PRESERVE_PATH=trueexport AO_STRICT=falseOrganization Variables (Long Prefix)
Section titled “Organization Variables (Long Prefix)”export AUDIOBOOK_ORGANIZER_LAYOUT="author-series-title"export AUDIOBOOK_ORGANIZER_REPLACE_SPACE="_"export AUDIOBOOK_ORGANIZER_REMOVE_EMPTY=trueexport AUDIOBOOK_ORGANIZER_USE_EMBEDDED_METADATA=trueexport AUDIOBOOK_ORGANIZER_FLAT=falseexport AUDIOBOOK_ORGANIZER_DRY_RUN=falseexport AUDIOBOOK_ORGANIZER_VERBOSE=trueexport AUDIOBOOK_ORGANIZER_PROMPT=falseBoolean Values
Section titled “Boolean Values”Environment variables accept multiple boolean formats:
- True:
true,True,TRUE,1,yes,Yes,YES - False:
false,False,FALSE,0,no,No,NO, (empty string)
export AO_VERBOSE=true # ✓ Worksexport AO_VERBOSE=TRUE # ✓ Worksexport AO_VERBOSE=1 # ✓ Worksexport AO_VERBOSE=yes # ✓ WorksExample Configurations
Section titled “Example Configurations”Scenario 1: Default Setup (Audiobookshelf)
Section titled “Scenario 1: Default Setup (Audiobookshelf)”Use case: Organize audiobooks with metadata.json files from Audiobookshelf
dir: "/media/audiobooks"out: "/media/organized"layout: "author-series-title"remove-empty: trueverbose: trueEnvironment variables:
export AO_DIR="/media/audiobooks"export AO_OUT="/media/organized"export AO_LAYOUT="author-series-title"export AO_REMOVE_EMPTY=trueexport AO_VERBOSE=trueCLI:
audiobook-organizer \ --dir=/media/audiobooks \ --out=/media/organized \ --layout=author-series-title \ --remove-empty \ --verboseScenario 2: Flat Mode for EPUBs
Section titled “Scenario 2: Flat Mode for EPUBs”Use case: Organize single-file EPUB audiobooks
dir: "/downloads/epubs"out: "/library/epubs"layout: "author-title"flat: true # Auto-enables use-embedded-metadataverbose: trueCLI:
audiobook-organizer \ --dir=/downloads/epubs \ --out=/library/epubs \ --layout=author-title \ --flatScenario 3: MP3 with Custom Field Mapping
Section titled “Scenario 3: MP3 with Custom Field Mapping”Use case: Organize MP3 audiobooks where “album” contains book title and “artist” contains author
dir: "/media/mp3-audiobooks"out: "/media/organized"use-embedded-metadata: truelayout: "author-series-title"
# Field mappingauthor-fields: "artist,album_artist,authors"title-field: "album"series-field: "series"track-field: "track"
# Optionsremove-empty: trueverbose: trueCLI equivalent:
audiobook-organizer \ --dir=/media/mp3-audiobooks \ --out=/media/organized \ --use-embedded-metadata \ --layout=author-series-title \ --author-fields="artist,album_artist,authors" \ --title-field="album" \ --remove-empty \ --verboseScenario 4: Docker Environment
Section titled “Scenario 4: Docker Environment”Use case: Run in Docker with environment variables
# .env fileAO_LAYOUT=author-titleAO_VERBOSE=trueAO_REMOVE_EMPTY=trueAO_USE_EMBEDDED_METADATA=truedocker-compose.yml:
version: '3.8'services: organizer: image: jeffsui/audiobook-organizer:latest volumes: - /media/source:/input:ro - /media/output:/output env_file: - .env command: --dir=/input --out=/outputScenario 5: CI/CD Automation
Section titled “Scenario 5: CI/CD Automation”Use case: Automated organization in GitHub Actions
name: Organize Audiobookson: push: paths: - 'audiobooks/**'jobs: organize: runs-on: ubuntu-latest env: AO_LAYOUT: author-series-title AO_VERBOSE: true AO_DRY_RUN: false steps: - uses: actions/checkout@v3 - name: Install organizer run: | wget https://github.com/jeeftor/audiobook-organizer/releases/latest/download/audiobook-organizer_Linux_x86_64.tar.gz tar xzf audiobook-organizer_Linux_x86_64.tar.gz - name: Organize run: ./audiobook-organizer --dir=./audiobooks --out=./organizedScenario 6: Rename with Template
Section titled “Scenario 6: Rename with Template”Use case: Rename files using custom template
# For rename commanddir: "/media/audiobooks"template: "{author} - {series} {series_number} - {track} - {title}"author-format: "last-first"author-fields: "narrators,authors"title-field: "title"verbose: truedry-run: false # Set to true for testingCLI:
audiobook-organizer rename \ --dir=/media/audiobooks \ --template="{author} - {series} {series_number} - {track} - {title}" \ --author-format=last-first \ --author-fields="narrators,authors"Configuration Tips
Section titled “Configuration Tips”Start with Defaults
Section titled “Start with Defaults”Begin with minimal config and add options as needed:
# Minimal configdir: "/media/audiobooks"verbose: trueRun with --dry-run to preview results, then add more options:
# After testingdir: "/media/audiobooks"out: "/media/organized"layout: "author-title"remove-empty: trueverbose: trueUse Config Files for Complex Setups
Section titled “Use Config Files for Complex Setups”For complicated field mappings or multiple options, config files are easier to manage than CLI flags:
# Complex MP3 field mappingauthor-fields: "narrators,authors,album_artist,artist,composer"title-field: "album,title,work"series-field: "series,album,grouping"track-field: "track,track_number,trck"Environment Variables for Scripting
Section titled “Environment Variables for Scripting”Use environment variables in scripts to avoid repetition:
#!/bin/bashexport AO_LAYOUT="author-series-title"export AO_VERBOSE=trueexport AO_REMOVE_EMPTY=true
audiobook-organizer --dir=/media/sci-fi --out=/library/sci-fiaudiobook-organizer --dir=/media/fantasy --out=/library/fantasyaudiobook-organizer --dir=/media/mystery --out=/library/mysteryCLI Flags for One-Time Changes
Section titled “CLI Flags for One-Time Changes”Override config/environment for specific runs:
# Usually use config file settings, but this time:audiobook-organizer \ --dir=/media/audiobooks \ --layout=author-only # Override config fileSeparate Configs for Different Libraries
Section titled “Separate Configs for Different Libraries”Use different config files for different audiobook collections:
# Config for Audiobookshelf collectionaudiobook-organizer --config=~/configs/audiobookshelf.yaml
# Config for MP3 collectionaudiobook-organizer --config=~/configs/mp3-audiobooks.yamlTroubleshooting Configuration
Section titled “Troubleshooting Configuration”Config file not found
Section titled “Config file not found”Check file location:
# List possible config file locationsls -la ~/.audiobook-organizer.yamlls -la ./.audiobook-organizer.yamlVerify YAML syntax:
# Test YAML syntax (if you have python)python -c "import yaml; yaml.safe_load(open('~/.audiobook-organizer.yaml'))"Environment variables not working
Section titled “Environment variables not working”Check variable names:
# List all AO_* variablesenv | grep AO_
# List all AUDIOBOOK_ORGANIZER_* variablesenv | grep AUDIOBOOK_ORGANIZER_Verify values:
echo $AO_DIRecho $AO_LAYOUTCLI flags not overriding config
Section titled “CLI flags not overriding config”Verify precedence:
# Use verbose to see what's being usedaudiobook-organizer --dir=/path --verboseLook for log output showing which config source is being used.
Unknown configuration options
Section titled “Unknown configuration options”Symptoms: Config file or environment variable seems to be ignored
Solution: Verify option names match exactly (case-sensitive for config file, uppercase for environment):
# ✗ WrongLayout: "author-title" # Capitalizeduse_embedded_metadata: true # Underscores instead of hyphens
# ✓ Correctlayout: "author-title"use-embedded-metadata: trueSee Also
Section titled “See Also”- CLI.md - Command-line reference with all flags
- METADATA.md - Field mapping deep dive
- LAYOUTS.md - Directory layout options
- Main README - Project overview
Feedback & Support
Section titled “Feedback & Support”- Bug reports: GitHub Issues
- Questions: GitHub Discussions Q&A