- # if output to dir, create the file
- if output_dir is not None:
- if make_dir:
- author = unicode(book_info.author)
- output_dir = os.path.join(output_dir, author)
- try:
- os.makedirs(output_dir)
- except OSError:
- pass
- if slug:
- output_file = os.path.join(output_dir, '%s.mobi' % slug)
- else:
- output_file = os.path.join(output_dir, os.path.splitext(os.path.basename(file_path))[0] + '.mobi')