Skip to content

Instantly share code, notes, and snippets.

@Grunerd
Forked from yismailuofa/get-books.sh
Created April 11, 2025 10:12
Show Gist options
  • Save Grunerd/6e428dfaeeb1626a2601af5b6d117a13 to your computer and use it in GitHub Desktop.
Save Grunerd/6e428dfaeeb1626a2601af5b6d117a13 to your computer and use it in GitHub Desktop.
Get URL Schemes For Your Apple Books on MacOS
#!/bin/bash
# Path to the BKLibrary file
BKLIBRARY_PATH=~/Library/Containers/com.apple.iBooksX/Data/Documents/BKLibrary
# Check if BKLibrary file exists
if [ ! -f "$BKLIBRARY_PATH/BKLibrary-"*".sqlite" ]; then
echo "BKLibrary file not found. Please make sure Books app is installed and has been opened at least once."
exit 1
fi
# Get the full path of the BKLibrary file
BKLIBRARY_FILE=$(ls "$BKLIBRARY_PATH"/BKLibrary-*.sqlite)
# Execute sqlite command to fetch book titles and asset IDs
sqlite3 "$BKLIBRARY_FILE" <<EOF
select ztitle, 'ibooks://assetid/' || zassetid from zbklibraryasset;
EOF
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment