Register Guidelines E-Books Search Today's Posts Mark Forums Read

Go Back   MobileRead Forums > E-Book Software > Calibre

Notices

Reply
 
Thread Tools Search this Thread
Old 07-16-2009, 12:47 PM   #1
Armaced
Enthusiast
Armaced began at the beginning.
 
Posts: 34
Karma: 10
Join Date: Jun 2009
Device: Sony eReader PRS-505
Switch Title and Author from command prompt

Is there an easy way to switch the Title and the Author of a set of files in a directory from the command line using Calibre?

I am not having any luck with the GUI - it has great features, but will not apply the changes.

The command line is working for me, but I have to modify the files one at a time, building the command line itself each time. I was hoping there would be some kind of "switch" key for just switching the title and author of a file.
Armaced is offline   Reply With Quote
Old 07-16-2009, 02:48 PM   #2
ilovejedd
hopeless n00b
ilovejedd ought to be getting tired of karma fortunes by now.ilovejedd ought to be getting tired of karma fortunes by now.ilovejedd ought to be getting tired of karma fortunes by now.ilovejedd ought to be getting tired of karma fortunes by now.ilovejedd ought to be getting tired of karma fortunes by now.ilovejedd ought to be getting tired of karma fortunes by now.ilovejedd ought to be getting tired of karma fortunes by now.ilovejedd ought to be getting tired of karma fortunes by now.ilovejedd ought to be getting tired of karma fortunes by now.ilovejedd ought to be getting tired of karma fortunes by now.ilovejedd ought to be getting tired of karma fortunes by now.
 
ilovejedd's Avatar
 
Posts: 5,111
Karma: 19597086
Join Date: Jan 2009
Location: in the middle of nowhere
Device: PW4, PW3, Libra H2O, iPad 10.5, iPad 11, iPad 12.9
What exactly are you trying to do? Are you importing books to Calibre and you want to have it automatically recognize the author and title of the books? If so, you don't need to rename your files. You just need to change the metadata detection within Calibre. I suggest you group all your files with similar naming schemes together then import them in separate batches in Calibre so you can use regular expressions that match the file naming convention for that specific batch.

You can change the regular expression for metadata detection via filename in Preferences > Advanced.
ilovejedd is offline   Reply With Quote
Advert
Old 07-16-2009, 04:31 PM   #3
myle00
Connoisseur
myle00 has a complete set of Star Wars action figures.myle00 has a complete set of Star Wars action figures.myle00 has a complete set of Star Wars action figures.myle00 has a complete set of Star Wars action figures.myle00 has a complete set of Star Wars action figures.
 
myle00's Avatar
 
Posts: 71
Karma: 422
Join Date: Jun 2009
Device: Palm Treo
I believe Armaced meant that in calibre when editing metadata there is an option to switch author with title.
myle00 is offline   Reply With Quote
Old 07-17-2009, 11:46 AM   #4
Armaced
Enthusiast
Armaced began at the beginning.
 
Posts: 34
Karma: 10
Join Date: Jun 2009
Device: Sony eReader PRS-505
Yes, Myle00 is correct. I am trying to use Calibre to correct metadata on existing .lrf files.
Armaced is offline   Reply With Quote
Old 07-17-2009, 12:24 PM   #5
kovidgoyal
creator of calibre
kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.
 
kovidgoyal's Avatar
 
Posts: 43,744
Karma: 22446736
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
It should be easy to write a script to do this in batch using lrf-meta, however, calibre does not have any command line batch processwing utilities.
kovidgoyal is offline   Reply With Quote
Advert
Old 07-17-2009, 02:59 PM   #6
Armaced
Enthusiast
Armaced began at the beginning.
 
Posts: 34
Karma: 10
Join Date: Jun 2009
Device: Sony eReader PRS-505
Thanks, kovidgoyal.
I am using lrf-meta now. I will research using scripts to batch process.
Armaced is offline   Reply With Quote
Old 08-14-2009, 03:30 PM   #7
Armaced
Enthusiast
Armaced began at the beginning.
 
Posts: 34
Karma: 10
Join Date: Jun 2009
Device: Sony eReader PRS-505
Sorry, I am still working on this (off and on). What scripting language would you use to do this?

I would think it would have to be able to load the file, set the name and title to variables, then run the command using the variables.
Armaced is offline   Reply With Quote
Old 08-14-2009, 03:45 PM   #8
itimpi
Wizard
itimpi ought to be getting tired of karma fortunes by now.itimpi ought to be getting tired of karma fortunes by now.itimpi ought to be getting tired of karma fortunes by now.itimpi ought to be getting tired of karma fortunes by now.itimpi ought to be getting tired of karma fortunes by now.itimpi ought to be getting tired of karma fortunes by now.itimpi ought to be getting tired of karma fortunes by now.itimpi ought to be getting tired of karma fortunes by now.itimpi ought to be getting tired of karma fortunes by now.itimpi ought to be getting tired of karma fortunes by now.itimpi ought to be getting tired of karma fortunes by now.
 
Posts: 4,552
Karma: 950151
Join Date: Nov 2008
Device: Sony PRS-950, iphone/ipad (Marvin/iBooks/QuickReader)
What OS are you using?
itimpi is offline   Reply With Quote
Old 08-14-2009, 06:08 PM   #9
Armaced
Enthusiast
Armaced began at the beginning.
 
Posts: 34
Karma: 10
Join Date: Jun 2009
Device: Sony eReader PRS-505
Windows Vista, so basically, ... DOS
Armaced is offline   Reply With Quote
Old 08-14-2009, 11:34 PM   #10
myle00
Connoisseur
myle00 has a complete set of Star Wars action figures.myle00 has a complete set of Star Wars action figures.myle00 has a complete set of Star Wars action figures.myle00 has a complete set of Star Wars action figures.myle00 has a complete set of Star Wars action figures.
 
myle00's Avatar
 
Posts: 71
Karma: 422
Join Date: Jun 2009
Device: Palm Treo
Which programming languages do you know? You can write it in any language that can launch cmd. I know java can do this and probably python.
Another question, how do you decide which books to switch title/author? Do you have a list or are they all in one folder? If you answer the last question I can probably write something in java to do this, given a file list or a folder to process.
myle00 is offline   Reply With Quote
Old 08-15-2009, 04:11 AM   #11
myle00
Connoisseur
myle00 has a complete set of Star Wars action figures.myle00 has a complete set of Star Wars action figures.myle00 has a complete set of Star Wars action figures.myle00 has a complete set of Star Wars action figures.myle00 has a complete set of Star Wars action figures.
 
myle00's Avatar
 
Posts: 71
Karma: 422
Join Date: Jun 2009
Device: Palm Treo
I was bored enough that I wrote it anyway. You can run using a folder with files or a text file listing the files to process. I attached the java file. You need to run the java file from command line with input.

However, first you need to compile the java file. I don't know if you know how to do that so here is the instructions. Go here http://java.sun.com/docs/books/tutor...ava/win32.html start at the section "Compile the Source File into a .class File" and follow the instructions. Basically you need to run this in cmd
Code:
javac SwitchCalTA.java
(Assuming you're in the directory where SwitchCalTA.java is in).

If cmd cannot recognize javac than you'll have to set it in the path. Go to Start>Right click Computer>properties>Advanced system settings>Environment Variables. Find Path in the System variables list, click edit and at the end of the "variable value" field enter ";C:\Program Files\Java\jdk1.6.0_07\bin;" DO NOT DELETE the text in that field, just append to the end. This assumes java is in that folder, else find where java is in your computer and add the path to the bin folder in path. Now run the javac code again. If it was compiled you'd see a class type file in your current folder.

Once it's complied you can run the program. To run it type
Code:
java SwitchCalTA "Folder.with.books or txt.file.with.books.list" "Folder.where.a.log.will.be.saved.to"
the command is composed of "java" than the name of the java file, followed by the folder path where the books are or a text file listing the full path of the files you wish to switch metadata, and followed by a folder where a log will be saved to. It will than start editing and printing the metadata it's changing. Here's how it looked on my cmd
Code:
C:\Users\xxxxxxxxxxxx>cd C:\22

C:\22>javac SwitchCalTA.java

C:\22>java SwitchCalTA "C:\Tests" "C:\Books"
I have 39 files to process


File: 0


"ebook-meta "C:\Tests\tAaa\Failed.txt""
Title               : Failed
Author(s)           : Unknown
"ebook-meta "C:\Tests\tAaa\Failed.txt" -t "Unknown""
Original metadata::
        Title               : Failed
        Author(s)           : Unknown

Changed metadata::
        Title               : Failed
        Author(s)           : Unknown
.......
.......
If you input a folder instead of a file list, it will edit the metadata for ALL the files in the directory, even those in sub-directories. Of course calibre ignores files that it cannot change metadata. Before you run it make sure you test it on a few individual files. You should probably also run it on a copy of the files and if it's ok, delete the originals.

Let me know if you have any questions.
Attached Files
File Type: zip SwitchCalTA.zip (2.3 KB, 249 views)
myle00 is offline   Reply With Quote
Old 08-15-2009, 12:25 PM   #12
Armaced
Enthusiast
Armaced began at the beginning.
 
Posts: 34
Karma: 10
Join Date: Jun 2009
Device: Sony eReader PRS-505
Wow, thanks myle00! That is perfect. I have the files all in a folder. I will give this a try.

I didn't mean to keep you up until 1 AM doing this...
Armaced is offline   Reply With Quote
Old 08-16-2009, 01:00 PM   #13
Armaced
Enthusiast
Armaced began at the beginning.
 
Posts: 34
Karma: 10
Join Date: Jun 2009
Device: Sony eReader PRS-505
I compiled the program and ran it. I can see it consider each file and then skip it.

Quote:
c:\java>java SwitchCalTA "C:\Users\Dad\Documents\My eBooks\test" "C:\Users\Dad\D
ocuments\My eBooks\test"
I have 1 files to process


File: 0


"ebook-meta "C:\Users\Dad\Documents\My eBooks\test\Makers of History - Xerxes -
Abbot_ Jacob.lrf""
Skipped File, continueing...
I looked into the code and found the function where it is skipping the file. It is an ELSE statement, where the condition is:

Quote:
if (author!=null&title!=null)
That condition makes total sense - I would not want to switch the author and the title if they were both NULL. However, the thing I see as the author and the title on this file are not NULL. This leads me to believe that we might be talking about different parameters.

I am going to keep investigating, as I know it is not your job to solve all my problems, and this is a great way for me to learn Java. (That is a terrific tutorial page you pointed me to, by the way).

To switch the title and author manually, I use the command:

Quote:
lrf-meta -t "Makers of History - Xerxes" -a "Abbot Jacob" "Makers of History - Xerxes - Abbot_ Jacob.lrf"
Immediately after switching the title and author, I load the file into Sony's eBook Library. So the title and author that I am interested in are the ones that will display in eBook library and are changed using lrf-meta.

I am going to investigate the functions "read metadata" and "find metadata". I suspect converting the line:

Quote:
cmd[2]= "\"ebook-meta \""+files[i].getAbsolutePath()+"\"\"";
into one that uses lrf-meta might lead to some happy results, but first, my wife needs me to mop the tiles in the kitchen.

Anyway, thanks again. I am having a lot of fun with this.
Armaced is offline   Reply With Quote
Old 08-16-2009, 02:58 PM   #14
Armaced
Enthusiast
Armaced began at the beginning.
 
Posts: 34
Karma: 10
Join Date: Jun 2009
Device: Sony eReader PRS-505
It just occured to me that I am probably missing the component to the application that is ebook-meta.

Quote:
c:\java>ebook-meta
'ebook-meta' is not recognized as an internal or external command,
operable program or batch file.
Of course, if I did not have that component, the function "read metadata" would fail to load the title & author into memory, so they would be NULL when the function "write metadata" fired.

I will investigate how to get that component as soon as I get done with the housework.
Armaced is offline   Reply With Quote
Old 08-16-2009, 02:59 PM   #15
myle00
Connoisseur
myle00 has a complete set of Star Wars action figures.myle00 has a complete set of Star Wars action figures.myle00 has a complete set of Star Wars action figures.myle00 has a complete set of Star Wars action figures.myle00 has a complete set of Star Wars action figures.
 
myle00's Avatar
 
Posts: 71
Karma: 422
Join Date: Jun 2009
Device: Palm Treo
Can you please send one such file that it skipped, if you want me to work on it - I like playing with these things. When I wrote it I didn't have any file in my db that calibre can actually "write" metadata to, only read, so I didn't test it completely. Also, I never used these metadata functions in calibre before so I'm not really sure of the difference between ebook-meta and xxx-meta.
However, I downloaded a test ltf file and here is the result
Code:
"ebook-meta "C:\22\Seal.lrf""
Title               : Privy Seals
Author(s)           : Ford,Ford Madox [Ford,Ford Madox]
Category            : Historical Fiction,,
Tags                : Historical Fiction
"ebook-meta "C:\22\Seal.lrf" -t "Ford,Ford Madox [Ford,Ford Madox]""
Original metadata::
        Title               : Privy Seals
        Author(s)           : Ford,Ford Madox [Ford,Ford Madox]
        Category            : Historical Fiction,,
        Tags                : Historical Fiction

Changed metadata::
        Title               : Ford,Ford Madox [Ford,Ford Madox]
        Author(s)           : Ford,Ford Madox [Ford,Ford Madox]
        Category            : Historical Fiction,,,
        Tags                : Historical Fiction
"ebook-meta "C:\22\Seal.lrf" -a "Privy Seals""
Original metadata::
        Title               : Ford,Ford Madox [Ford,Ford Madox]
        Author(s)           : Ford,Ford Madox [Ford,Ford Madox]
        Category            : Historical Fiction,,,
        Tags                : Historical Fiction

Changed metadata::
        Title               : Ford,Ford Madox [Ford,Ford Madox]
        Author(s)           : Privy Seals [Seals, Privy]
        Category            : Historical Fiction,,,,
        Tags                : Historical Fiction
File: 2
If you upload a skipped file, I'll experiment with it.

btw, java trails http://java.sun.com/docs/books/tutorial/ is a really good resource for learning the java language. You can learn the whole thing there...



Edit: I just saw your post. This can mean two things, either calibre program files is not in your path, but than lrf-meta shouldn't work either, or you don't have the latest v. of calibre. For this to work "C:\Program Files\calibre" has to be in your path variable. If it isn't than add it as per instructions for adding java bin to your path.

Last edited by myle00; 08-16-2009 at 03:05 PM.
myle00 is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Changing from Title-Author to Author - Title Amalthia Calibre 17 01-22-2017 11:20 PM
Sort by author AND title bookends Calibre 2 05-09-2010 01:55 PM
Need help using mobidedrm - stuck on command prompt weeziepepper Kindle Formats 7 02-11-2010 11:22 AM
Any suggestion to switch the Title and Author fields? evertonhs Calibre 1 10-31-2009 11:04 PM
Launching Calibre from Command Prompt itimpi Calibre 7 04-02-2009 07:26 PM


All times are GMT -4. The time now is 06:11 AM.


MobileRead.com is a privately owned, operated and funded community.