Created
April 21, 2022 10:36
-
-
Save jianyun8023/a4b8e9568f896a09e495fb5ff12f1d20 to your computer and use it in GitHub Desktop.
ebook convert base on eCore
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
workdir=$(pwd) | |
filepath=$1 | |
format=$2 | |
outdir=$3 | |
book_convert(){ | |
filepath=$1 | |
format=$2 | |
tmp_dir="$HOME/Downloads/eCoreCmdtmp/$(uuidgen)" | |
mkdir -p $tmp_dir | |
# rm -rf "$HOME/Downloads/eCoreCmdtmp" | |
dirname=$(dirname "$filepath") | |
input_file_type=$(echo ".${filepath##*.}") | |
basename=$(basename -s $input_file_type "$filepath") | |
origin_name=$(basename "$filepath") | |
newfile_neme=$basename"."$format | |
echo "- Convert $basename to $format" | |
echo "$workdir/eCoreCmd c $dirname/$origin_name $outdir/$newfile_neme $tmp_dir" | |
$workdir/eCoreCmd c "$dirname/$origin_name" "$outdir/$newfile_neme" "$tmp_dir" | |
rm -rf $tmp_dir | |
echo "- Done! $origin_name , output file: $newfile_neme" | |
} | |
book_convert "$1" $2 |
The reason for writing this script is that eCore's commands are so difficult to use.
*********************************************************************
Epubor eCore
Version : 1.0.9.970
Copyright : https://www.epubor.com/ecore.html
Licensed to : Epubor https://www.epubor.com
AuthorityEndDate : 2030-07-01
*********************************************************************
Format:
eCoreCmd g <InputFile> <TempDirectory> <MetaDataFile> <CoverImageFile>
eCoreCmd s <InputFile> <TempDirectory> <MetaDataFile>
eCoreCmd s <InputFile> <TempDirectory> [-t <title>] [-a <author>] [-p <publisher>] [-l <language>] [-d <publishdate>] [-isbn <ISBN>] [-asin <ASIN>] [-desc <description>] [-cover <cover file name>]
eCoreCmd c <InputFile> <OutputFile> <TempDirectory> [-l <language>] [-v] [-tre <regexstr>]
Epubor Ultimate is NOT FREE software!
@caihk We use it for research purposes only. Alternatively, you can send an email to request their development license.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This script is used to simplify the eCore tool to convert books.
The new version of eCore is available from Epubor Ultimate
eCore is only available in macOS and Windows versions. I am using this script on macOS.
curl -o epubor_ultimate.zip 'https://download.epubor.com/epubor_ultimate.zip' unzip epubor_ultimate.zip pkgutil --expand-full Ultimate.pkg out r
You can find the following three files inside
out/Payload/Contents/MacOS/plugins
, which are the conversion tools we need.eCoreCmd
is the executability file,eCore.dylib
is the dependency library, andeCore.dat
is the license file, currently as of 2030.You can copy these files and put them in the new directory
eCore
, save the scripts from my gist to this directory as well, and they will be ready to use.Like this:
./book-convert.sh /path/xxx.azw3 epub /path/output-dir
I can process 3000 epub files in about 20 minutes or so by using 8 tasks to convert in parallel.
ls book/ | xargs -P8 -I{} ./book-convert.sh "book/{}" epub /path/output-dir