1

I have a number of EPUB titles that need renaming, from the likes of "1631214659.epub" to "Moon's Napa and Sonoma" and so on. They load into Calibre under their actual titles, but I still need to rename the source file appropriately for archiving. I've tried copying each file's string of identifier numbers into Google after the search term EPUB, and that usually works, but then I have to copy the resulting title text string and paste it into the file name each time. I'm wondering if there's an app that "reads" the file and can display or even change the book title on the fly.

I know nothing about ebook conversion beyond what Calibre affords, so if the info is viewable that way, I've missed it.

  • What is your operating system name and version? Or what is your reader device brand and model? In general, you must find the EPUB files you want to rename, then you must have permissions to rename those files in that directory. Are you trying to use Calibre to name the physical files? If so you might have to use your OS file manager to rename them. – Bulrush Nov 22 '17 at 12:13
  • The question perhaps is not about filename, but "title of the document" of changes into the Container .xml of EPUB. – Peter Krauss Jun 15 '18 at 16:31
2

I wrote a small python script to do that.

pip install epub

Install the epub library and run the below script with a sibling directory containing all your epub files to be renamed.

import os
import glob
import epub

dirName = "books" #the folder containing your epub files, should be in the
                  #directory which contains the script.
                  
for File in glob.glob(dirName + "\\*.epub"):
    with epub.open_epub(File) as book:
        title = book.opf.metadata.titles[0][0]

    os.rename(File, dirName + "\\" + title + ".epub")

Note : The title should not be too long (not exceeding your os' filename limit).

| improve this answer | |
1

The question is not too clear.

Is it the case that you simply want to rename the file containing the epub book, so that the name of the file is then the title of the book with the suffix .epub? That can be done very simply, using a command that extracts the book title from the file (see Command line extraction of metadata (title. author) from epub file), and make it the new file name. The exact command depends on your operating system (I run Linux). Supposing your file is called 12345.epub, in Linux shell (command line) you would write:

 mv 12345.epub "`exiftool -T -Title 12345.epub`".epub

Of course this can be iterated over a list of files, or all the files in a directory. I did some tests that worked.

exiftool is a very general command to extract metadata from files. It is written in Perl (my quick guess) and I expect it to be available in all environments.

| improve this answer | |
1
  • For Windows cmd.exe: ren 12345.epub mybookname.epub
  • For linux based OS: mv 12345.epub mybookname.epub
  • For Windows gui: use file manager, click once on the file. Hit F2 to enter "rename mode". Only the base filename should be selected (not the extension). Type the new name.
| improve this answer | |
0

I haven't verified this to be the case, but I'm pretty sure it works.

An epub is simply a zip file with its file extension renamed to .epub. The ebook name comes from the package.opf . Then look for the information in the line: <dc:title>Your Title </dc:title>.

But even knowing that is unnecessary. I would throw copy all your epub files into a separate directory, then add them to an app like Adobe Digital Editions or Readium (or even Calibre). Click on INFO or PROPERTIES TO view the ebook title (i.e., dc:title) and see what the file is named.

Then in Windows explorer you use this information to edit the file name of the original epub file. Tedious, but it works. Another way to do is to right-click the ebook, select, EDIT THE EBOOK, and then choose File --> Save a Copy --> (input your preferred name in the dialogue and press Save).

BTW, I had this exact same problem with earlier versions of Project Gutenberg files (which had cryptic file names). In the last year or so PG corrected it so that (most) file names are comprehensible to humans.

| improve this answer | |
0

Calibre doesn't change the source, but if you open the containing folder (after right click on the book title in Calibre) you'll see an EPUB there with the title as stem of the filename (and .epub as extension). On any change of title in Calibre, the name of that file changes as well.

| improve this answer | |
0

If you switch your calibre library to a new location, all changes made in metadata is automatically reflected in the new location. You can later switch to the old location if you want.

| improve this answer | |
0

Recently, I came across a set of scripts called ebook-tools that can solve this problem. Works like a charm.

| improve this answer | |
0

This is a long time after the question - but it doesn't seem to have a simple answer yet so: The OP said his books"load into Calibre under their actual titles" which means the metadata in the files is OK. The simplest way "to rename the source file appropriately for archiving" is to use Calibre's "Save to Disk" function.

In Calibre go to Preferences/Saving to Disk and create the naming pattern you want. e.g. something like {title} - {authors}. You can also set a preferred output format to automatically change mobi to epub or whatever.

Then you can import your numbered books to Calibre and use the Save to Disk feature to output your correctly named archive copy.

NB by this time you will have 3 Copies of each ebook: your original, Calibre's copy in it's library and the new renamed output version. If all you want is a copy easily identifiable by the file name then perhaps a regular backup of the Calibre library folder is all you need.

| improve this answer | |
-1

If you want to rename the book itself instead of the epub, you have to find the toc.ncx file you can open it with a wordpad or notepad in your cp. Find the title of the book or whatever jargon text it was then change it to your liking.

| improve this answer | |
  • It doesn't work. "sigh" – Phreasilva Apr 11 '19 at 11:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.