Thanks, for replying, I used a tmp directory in the current directory so that way I didn't mess up the other things in /tmp when I was creating the code.
But, I figured out a way to get the script to work.
Here's the code if anyone is interested.
Code:
#!/bin/sh
#needs xml_grep from the package xml-twig-tools
mkdir "tmp" # creates temporary workspace
for i in *.epub; do #checks that there are epub books in directory
if [ -e "$i" ]; then
unzip "$i" -d "tmp/$i" #unzips ebooks and gets information for new name
a=`find "tmp/$i/" -name *.opf`
if [ -e "$a" ]; then
name=`xml_grep 'dc:title' "$a" --text_only`
author=`xml_grep 'dc:creator' "$a" --text_only`
r=`find "tmp/$i/META-INF/" -name "rights.xml"` #checks to see if ebook is ecrypted and decrypts the ebook
if [ -e "$r" ]
then
for key in ~/bin/*.b64; do
python ~/bin/ignobleepub.pyw "$key" "$i" "$name - $author.epub"
rm "$i"
done
else
mv "$i" "$name - $author.epub" #renames epub
fi
fi
chmod a+rw "tmp/$i/" #cleans up workspace
rm -rf "tmp/$i/"
fi
done
rmdir "tmp/"