Skip to content

Instantly share code, notes, and snippets.

@jianyun8023
Created April 21, 2022 10:36
Show Gist options
  • Save jianyun8023/a4b8e9568f896a09e495fb5ff12f1d20 to your computer and use it in GitHub Desktop.
Save jianyun8023/a4b8e9568f896a09e495fb5ff12f1d20 to your computer and use it in GitHub Desktop.
ebook convert base on eCore
#!/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
@jianyun8023
Copy link
Author

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>]

image

@caihk
Copy link

caihk commented Nov 15, 2022

Epubor Ultimate is NOT FREE software!

@jianyun8023
Copy link
Author

@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