A simple epub file renaming utility

I have a couple of epub files that have random names assigned to them, and I wanted to rename them based on their metadata, in the form Author - Title. Below is what I came up with:


from zipfile import ZipFile
import lxml.etree
import os.path
import shutil
import sys

namespaces = {

def main():
    if len(sys.argv) != 2:
        print "Need a path."

    fpath = sys.argv[1]
    zip = ZipFile(fpath)
    meta = zip.read("META-INF/container.xml")
    e = lxml.etree.fromstring(meta)
    rootfile = e.xpath("/u:container/u:rootfiles/u:rootfile", 
    path = rootfile.get('full-path')
    opf = zip.read(path)
    e = lxml.etree.fromstring(opf)
    title = e.xpath("//dc:title", namespaces=namespaces)[0].text
    author = e.xpath("//dc:creator", namespaces=namespaces)[0].text

    base = os.path.dirname(fpath)
    new_name = "%s - %s.epub" % (author, title)
    shutil.move(fpath, os.path.join(base, new_name))

if __name__ == "__main__":