Book library organizer
Skill niki8885/book-library-analyzer/skills/book-library-organizer
Rename and reorganize a folder of ebooks and audiobooks: scan one or multiple directories, choose a file-naming format (author, title, year, series, language…), pick a folder sorting scheme (by author, genre, year, or discipline depth for scientific libraries), select which metadata fields to include in the catalog, choose output format (Markdown / CSV / XLSX / SQLite), preview every planned rename, execute with an undo log. Saves a rules file so all settings are remembered and reused on the next run without re-asking. TRIGGER when the user wants to rename book files, sort a library into folders, or build a structured catalog with custom fields — e.g. "rename my books", "organize library by author", "sort audiobooks by year", "put books into genre folders", "make a CSV of my books with author and language", "rename to Author - Title format", "organize scientific library by discipline", "create an Excel catalog", "export my library to a database".From its SKILL.md
npx -y skills add niki8885/book-library-analyzer --skill book-library-organizerAssembled from the repository path, not quoted from the project. Check it against their README if it does not work.
One thing to look at
- 0 stars0 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.
SKILL.md
12.7 KB, as published. Nobody here has run it
Book Library Organizer
Rename files and reorganize folders in a book library, then produce a catalog with user-selected metadata fields. Every rename is previewed before execution. An undo log lets the user reverse all changes. A rules file persists all settings so re-running the skill is one keystroke, not a questionnaire.
Language rule: Respond in the user's language. Metadata values (titles, author names) stay in their original language unless the user asks otherwise.
Step 0 — Resolve flags and load saved settings
Special flags
--undo <path-to-rename-log.tsv>→ go directly to Step 8 (Undo mode), skip everything else.--dry-run→ run the full flow but stop at Step 6 without writing any files.
Check for saved rules
Look for library-rules.json in the target folder(s) or at the path specified via
--rules. If found, read it and show a one-line summary:
"Found saved rules from [date]:
{author} - {title} ({year})· sorted by author · XLSX+CSV+DB"
Then ask:
- Use saved rules — skip Steps 2–4, proceed straight to scanning and executing
- Edit rules — show current values, let the user change specific settings
- Start fresh — ignore saved rules, go through all steps
If no rules file exists, proceed through all steps normally.
Check for saved index
Look for .library-index.json in each target folder. If found, note its last_scan date
and total book count — you'll use it in Step 1 to skip books that haven't changed.
Step 1 — Gather target folders and scan
Ask the user for one or more folder paths to process:
- Single path:
/home/user/Books - Multiple paths, comma-separated:
D:\Books, E:\Audiobooks - Root with "all subfolders" — treat each immediate subfolder as a separate section
Reuse existing catalog: check each target folder for library-catalog.md (written by
the book-library-analyzer skill). Offer to pull metadata from it — saves web searches.
Run the scanner for folders without an existing catalog. Locate scan_library.py
bundled with this skill:
**/book-library-organizer/scripts/scan_library.py
Use Glob from the home directory. Take the first match.
python "<script-path>" "<folder>"
(Try py on Windows if python is not on PATH.)
Incremental mode: if .library-index.json exists, compare the scan results with the
index. Books already in the index whose file hasn't changed (same path, same size) skip
the rename-plan and catalog steps — they are written to the output using their existing
index data. Only new or changed files go through Steps 2–6 fully.
Report: "Found N books total — X new, Y unchanged (from index), Z changed."
Step 2 — Choose naming format
Show five preset options illustrated with 2–3 real examples from the scan. Ask the user to pick one or define a custom pattern.
| # | Format | Example |
|---|---|---|
| 1 | {author} - {title} ({year}) | George Orwell - 1984 (1949) ← recommended |
| 2 | {author} - {title} | George Orwell - 1984 |
| 3 | {last}, {first} - {title} ({year}) | Orwell, George - 1984 (1949) |
| 4 | {title} - {author} ({year}) | 1984 - George Orwell (1949) |
| 5 | {series} {num:02d}. {title} ({author}, {year}) | Dune 01. Dune (Herbert, 1965) |
| 6 | Custom — enter your own pattern |
Available tokens:
| Token | Value | Example |
|---|---|---|
{author} | Full author name | George Orwell |
{last} | Author last name | Orwell |
{first} | Author first name | George |
{title} | Book title | 1984 |
{year} | Publication year | 1949 |
{series} | Series name | Dune Chronicles |
{num} | Series number, zero-padded | 01 |
{lang} | Language code | en, ru, de |
{genre} | Primary genre | Dystopia |
{ext} | File extension without dot | epub |
Missing values: use _Unknown_ as placeholder. Series tokens are silently omitted for
standalone books. Offer a quick web search for books where {year} or {author} is missing
and the format requires it.
Sanitize filenames: strip OS-illegal characters (\ / : * ? " < > | on Windows;
: on macOS/Linux). Warn if any titles had characters removed.
Step 3 — Choose folder organization
Ask: "General library or scientific/academic?" — then branch:
General library
| Option | Structure | Example |
|---|---|---|
| Flat (default) | Rename in place, no subfolders | Books/George Orwell - 1984 (1949).fb2 |
| By author | {Last, First}/ | Books/Orwell, George/... |
| By genre | {Genre}/ | Books/Dystopia/... |
| By year | {Year}/ | Books/1949/... |
| By genre → author | {Genre}/{Author}/ | Books/Dystopia/George Orwell/... |
| By author → series | {Author}/{Series}/ | Books/Frank Herbert/Dune/... |
Genre-based sorting requires genre data; offer a quick targeted search for books missing it,
or fall back to an _Uncategorized/ folder.
Scientific / academic library
Ask: "How deep should the discipline hierarchy go?"
| Level | Structure | Example |
|---|---|---|
| L1 | {Discipline}/ | Science/Book.pdf |
| L2 | {Discipline}/{Field}/ | Science/Biology/Book.pdf |
| L3 | {Discipline}/{Field}/{Specialization}/ | Science/Biology/Genetics/Book.pdf |
Determine discipline from genre tags and title analysis. Books with unclear discipline go
into _Unclassified/ and are listed in the Step 5 preview for manual reassignment.
Step 4 — Choose catalog fields and output formats
Fields
Present available fields with recommended defaults checked:
Select catalog fields:
[x] new_path — file path after rename
[ ] old_path — original path before rename
[x] title — book title
[x] author — author name
[x] year — year of first publication
[ ] publisher — publisher name (rarely in metadata)
[x] language — language code (en / ru / de…)
[x] series — series name
[x] series_num — part number within series
[x] genre — primary genre
[ ] tags — thematic tags (dystopia, coming-of-age…)
[x] format — file extension
[ ] size_mb — file size in MB
[ ] goodreads — Goodreads rating (requires library-catalog.md)
[ ] description — short description (requires library-catalog.md)
Output formats
Ask which formats to generate (can select multiple):
| # | Format | File | Best for |
|---|---|---|---|
| 1 | Markdown table | library-catalog.md | Human-readable, git-friendly |
| 2 | CSV | library-catalog.csv | Excel, Notion, Airtable import |
| 3 | XLSX | library-catalog.xlsx | Excel with bold header row, auto-filter ready |
| 4 | SQLite | library-catalog.db | Querying with SQL, apps, scripts |
| 5 | All of the above ← recommended |
Catalog stem name: default is library-catalog. Ask if the user wants a different name.
Output location: default is the first target folder. Respects --output <path> if passed.
If the folder is not writable, notify and ask for an alternative location.
XLSX and SQLite are written by the bundled script. Locate catalog_writer.py
bundled with this skill:
**/book-library-organizer/scripts/catalog_writer.py
Use Glob from the home directory. Take the first match.
Build the input JSON and pipe it to the script:
echo <catalog-json> | python "<catalog_writer-path>" --all "<stem>"
The script writes <stem>.csv, <stem>.xlsx, and <stem>.db in one pass.
Step 5 — Preview and confirm
Never rename or write files before the user confirms.
Show the first 20 planned changes:
RENAME PREVIEW (showing 20 of N)
OLD PATH → NEW PATH
──────────────────────────────────────────────────────────────────
Books/1984_orwell.fb2 → Books/Orwell, George/George Orwell - 1984 (1949).fb2
Books/dune_part1.epub → Books/Herbert, Frank/Dune/Frank Herbert - Dune (1965).epub
Books/mystery_book.pdf → Books/George Orwell - _Unknown_ (1945).pdf ⚠ missing title
After the table, list warnings by category:
- Conflicts — two books would get identical filenames; suggest adding
{lang}or(2)suffix - Missing metadata — books where key tokens are
_Unknown_; list old filename + which field is missing - Character sanitization — titles that had illegal characters stripped
- Unclassified (scientific mode) — books with unclear discipline
Ask: "Proceed with all N renames? Or adjust the plan?"
Stop here if --dry-run was passed.
Step 6 — Execute renames
After confirmation:
-
Write undo log first (before any rename): Save
rename-log.tsvto the output folder:# rename-log.tsv created <datetime> old_path\tnew_path Books/1984_orwell.fb2\tBooks/Orwell, George/George Orwell - 1984 (1949).fb2 -
Create destination folders that don't yet exist.
-
Rename files one by one. On each error (permission denied, path too long), log the failure and continue — report all failures at the end.
-
Write the catalog in all chosen formats (see Step 4). For XLSX and SQLite, run
catalog_writer.pyvia Bash. For Markdown, write directly with the Write tool. -
Report in chat: N renamed, X failures, catalog paths, undo log path.
Step 7 — Save rules and update index
After a successful run, always save two files to the output folder:
library-rules.json — settings for next run
{
"version": "1.1",
"created": "<ISO date>",
"updated": "<ISO date>",
"folders": ["D:\\Books"],
"naming_format": "{author} - {title} ({year})",
"organization": {
"type": "by_author",
"library_type": "general",
"scientific_depth": null
},
"catalog": {
"fields": ["new_path", "title", "author", "year", "language", "series", "series_num", "genre", "format"],
"formats": ["md", "csv", "xlsx", "db"],
"output_path": "D:\\Books",
"stem": "library-catalog"
}
}
.library-index.json — persistent book index
Key each entry by its new_path (relative to the folder root). On the next run, files
already in the index whose path and size match are skipped — no re-scanning or re-enriching.
{
"version": "1.1",
"last_scan": "<ISO datetime>",
"total": 42,
"books": {
"Orwell, George/George Orwell - 1984 (1949).fb2": {
"title": "1984",
"author": "George Orwell",
"year": 1949,
"genre": "Dystopia",
"language": "en",
"series": null,
"series_num": null,
"format": "fb2",
"size_mb": 0.5,
"goodreads": "4.19 (4.1M)",
"description": "...",
"indexed": "<ISO date>"
}
}
}
Tell the user: "Rules saved to library-rules.json. Next run will skip the setup questions.
Index saved to .library-index.json — N new books added."
Step 8 — Undo mode
Triggered by --undo <path-to-rename-log.tsv> or the user explicitly asking to reverse renames.
Read the log. Reverse every new_path → old_path pair. Check that the new_path files
still exist (they may have been moved again since). Report files that can't be undone.
Ask for confirmation, then execute. Offer to delete any empty folders left behind.
After undo, mark the log file as reversed (append a # UNDONE <datetime> line) so it isn't
accidentally run twice.