the_earnest/dotfiles

#/bin/bash

# Looks for all MOBI files in the current directory and removes
# those for which an identically named EPUB exists in the current
# directory also.
# In other words, for every ebook in the current directory that
# exists as both an EPUB and a MOBI/LIT/PRC/AZW3, it removes the latter.

for ext in mobi prc lit azw3 rtf pdb fb2
do
	echo "deleting paired ${ext}s"
	for i in *.$ext
	do
		if [[ -e "${i%.$ext}.epub" ]]
		then
			rm -v "$i"
		fi
	done
done