-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbooks_convert.sh
29 lines (24 loc) · 975 Bytes
/
books_convert.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#!/bin/bash
# Script for converting epub or fb2 files to Kindle's mobi
# Prerequisites: Calibre
# You can install it with yum install calibre
# pacman -S calibre or apt install calibre
# Defining of the input directory
in_dir="$HOME/Downloads/"
# Output directory is the directory where the books would be saved
out_dir="$HOME/Documents/books/"
# out_extension is the target extension
out_extension=".mobi"
cd "$in_dir" || exit
shopt -s nullglob
# looping through all files with .epub or .fb2 extension in the $in_dir
for book in *.epub *.fb2
do
filename="${book%.*}"
out_file="$out_dir$filename$out_extension"
in_file="$in_dir$book"
# ebook-convert is a command line utility for converting e-books into different format, it requires installed Calibre
ebook-convert "$in_file" "$out_file" 1>/dev/null || exit
echo "$book has been successfully converted and saved in $out_dir"
echo "====================================================="
done