07-16-2009, 12:47 PM | #1 |
Enthusiast
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. |
07-16-2009, 02:48 PM | #2 |
hopeless n00b
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. |
Advert | |
|
07-16-2009, 04:31 PM | #3 |
Connoisseur
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.
|
07-17-2009, 11:46 AM | #4 |
Enthusiast
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.
|
07-17-2009, 12:24 PM | #5 |
creator of calibre
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.
|
Advert | |
|
07-17-2009, 02:59 PM | #6 |
Enthusiast
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. |
08-14-2009, 03:30 PM | #7 |
Enthusiast
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. |
08-14-2009, 03:45 PM | #8 |
Wizard
Posts: 4,552
Karma: 950151
Join Date: Nov 2008
Device: Sony PRS-950, iphone/ipad (Marvin/iBooks/QuickReader)
|
What OS are you using?
|
08-14-2009, 06:08 PM | #9 |
Enthusiast
Posts: 34
Karma: 10
Join Date: Jun 2009
Device: Sony eReader PRS-505
|
Windows Vista, so basically, ... DOS
|
08-14-2009, 11:34 PM | #10 |
Connoisseur
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. |
08-15-2009, 04:11 AM | #11 |
Connoisseur
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 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" 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 ....... ....... Let me know if you have any questions. |
08-15-2009, 12:25 PM | #12 |
Enthusiast
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... |
08-16-2009, 01:00 PM | #13 | ||||
Enthusiast
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:
Quote:
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:
I am going to investigate the functions "read metadata" and "find metadata". I suspect converting the line: Quote:
Anyway, thanks again. I am having a lot of fun with this. |
||||
08-16-2009, 02:58 PM | #14 | |
Enthusiast
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:
I will investigate how to get that component as soon as I get done with the housework. |
|
08-16-2009, 02:59 PM | #15 |
Connoisseur
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 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. |
Thread Tools | Search this Thread |
|
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 |