Skip to content

Instantly share code, notes, and snippets.

@fabiolimace
Last active November 24, 2025 03:30
Show Gist options
  • Select an option

  • Save fabiolimace/b572d64f97d9088744d0c3b3658a3050 to your computer and use it in GitHub Desktop.

Select an option

Save fabiolimace/b572d64f97d9088744d0c3b3658a3050 to your computer and use it in GitHub Desktop.
List Amazon Book IDs of all ebooks in a Calibre Library
#!/bin/bash
#
# List all MOBI-ASIN codes extracted from OPF files.
#
# Usage
#
# calibre-list-mobi-asin.sh LIBRARY
#
LIBRARY=${1}
[ -d "$LIBRARY" ] || LIBRARY=$(pwd);
time find "$LIBRARY" -type f -name "*.opf" -exec grep -E '<dc:identifier opf:scheme="MOBI-ASIN">B[A-Z0-9]{9}</dc:identifier>' "{}" \; \
| grep -E --only-matching 'B[A-Z0-9]{9}' | sort | tee ~/calibre-list-mobi-asin.v`date +"%Y%m%d"`.txt
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment