Register Guidelines E-Books Today's Posts Search

Go Back   MobileRead Forums > E-Book Software > Calibre

Notices

Reply
 
Thread Tools Search this Thread
Old 10-02-2010, 02:27 PM   #1
dkritso109
Enthusiast
dkritso109 began at the beginning.
 
Posts: 43
Karma: 10
Join Date: Jun 2010
Device: Kindle 3
Need Help With "Regular Expression Syntax"

Hey all,
I am seriously confused with Regular Expression Syntax. All of my file names are like this:
----------------------------------------------------------------------------------------
Single Books:

Armstrong, Kelley - Jauría

Book Series:

Armstrong, Kelley - Otherworld 1 - Bitten
----------------------------------------------------------------------------------------
Calibre does not pick up any information at all from these filenames, the title nor the author. Can someone please forward me a syntax that works for this type of file name system?
dkritso109 is offline   Reply With Quote
Old 10-02-2010, 03:33 PM   #2
Manichean
Wizard
Manichean is the 'tall, dark, handsome stranger' all the fortune-tellers are referring to.Manichean is the 'tall, dark, handsome stranger' all the fortune-tellers are referring to.Manichean is the 'tall, dark, handsome stranger' all the fortune-tellers are referring to.Manichean is the 'tall, dark, handsome stranger' all the fortune-tellers are referring to.Manichean is the 'tall, dark, handsome stranger' all the fortune-tellers are referring to.Manichean is the 'tall, dark, handsome stranger' all the fortune-tellers are referring to.Manichean is the 'tall, dark, handsome stranger' all the fortune-tellers are referring to.Manichean is the 'tall, dark, handsome stranger' all the fortune-tellers are referring to.Manichean is the 'tall, dark, handsome stranger' all the fortune-tellers are referring to.Manichean is the 'tall, dark, handsome stranger' all the fortune-tellers are referring to.Manichean is the 'tall, dark, handsome stranger' all the fortune-tellers are referring to.
 
Manichean's Avatar
 
Posts: 3,130
Karma: 91256
Join Date: Feb 2008
Location: Germany
Device: Cybook Gen3
There's a tutorial available in Calibre's user manual.
Manichean is offline   Reply With Quote
Old 10-02-2010, 04:00 PM   #3
kacir
Wizard
kacir ought to be getting tired of karma fortunes by now.kacir ought to be getting tired of karma fortunes by now.kacir ought to be getting tired of karma fortunes by now.kacir ought to be getting tired of karma fortunes by now.kacir ought to be getting tired of karma fortunes by now.kacir ought to be getting tired of karma fortunes by now.kacir ought to be getting tired of karma fortunes by now.kacir ought to be getting tired of karma fortunes by now.kacir ought to be getting tired of karma fortunes by now.kacir ought to be getting tired of karma fortunes by now.kacir ought to be getting tired of karma fortunes by now.
 
kacir's Avatar
 
Posts: 3,450
Karma: 10484861
Join Date: May 2006
Device: PocketBook 360, before it was Sony Reader, cassiopeia A-20
Quote:
Originally Posted by Manichean View Post
There's a tutorial available in Calibre's user manual.
I am aware that there is tutorial available ;-), but I haven't been able to figure out how to parse
Armstrong, Kelley - Otherworld 1 - Bitten
so I get author name Kelley Armstrong

I can extract author, title, series, even make series optional(*), yet I haven't found a way of how to parse (LastName, FirstName|Firstname Lastname) to the {authors} field.


(*) I *think*, because I found one unpleasant limitation in python RE engine used to parse names in calibre
kacir is offline   Reply With Quote
Old 10-02-2010, 04:12 PM   #4
dkritso109
Enthusiast
dkritso109 began at the beginning.
 
Posts: 43
Karma: 10
Join Date: Jun 2010
Device: Kindle 3
see my dilemma??? can anyone give me an expression that most closely extracts the relevant data i need into the metadata card?
dkritso109 is offline   Reply With Quote
Old 10-02-2010, 04:15 PM   #5
Manichean
Wizard
Manichean is the 'tall, dark, handsome stranger' all the fortune-tellers are referring to.Manichean is the 'tall, dark, handsome stranger' all the fortune-tellers are referring to.Manichean is the 'tall, dark, handsome stranger' all the fortune-tellers are referring to.Manichean is the 'tall, dark, handsome stranger' all the fortune-tellers are referring to.Manichean is the 'tall, dark, handsome stranger' all the fortune-tellers are referring to.Manichean is the 'tall, dark, handsome stranger' all the fortune-tellers are referring to.Manichean is the 'tall, dark, handsome stranger' all the fortune-tellers are referring to.Manichean is the 'tall, dark, handsome stranger' all the fortune-tellers are referring to.Manichean is the 'tall, dark, handsome stranger' all the fortune-tellers are referring to.Manichean is the 'tall, dark, handsome stranger' all the fortune-tellers are referring to.Manichean is the 'tall, dark, handsome stranger' all the fortune-tellers are referring to.
 
Manichean's Avatar
 
Posts: 3,130
Karma: 91256
Join Date: Feb 2008
Location: Germany
Device: Cybook Gen3
You could always extract the lastname, firstname into {authors} and fix it up with search & replace later. Other than that, off the top of my head, I can't think of any solution.
Manichean is offline   Reply With Quote
Old 10-02-2010, 04:20 PM   #6
dkritso109
Enthusiast
dkritso109 began at the beginning.
 
Posts: 43
Karma: 10
Join Date: Jun 2010
Device: Kindle 3
i have literaly thousands of books in that format, we are talking like a month's work of copy and pasting. i have gone over the tutorial with no avail.
dkritso109 is offline   Reply With Quote
Old 10-02-2010, 04:25 PM   #7
Manichean
Wizard
Manichean is the 'tall, dark, handsome stranger' all the fortune-tellers are referring to.Manichean is the 'tall, dark, handsome stranger' all the fortune-tellers are referring to.Manichean is the 'tall, dark, handsome stranger' all the fortune-tellers are referring to.Manichean is the 'tall, dark, handsome stranger' all the fortune-tellers are referring to.Manichean is the 'tall, dark, handsome stranger' all the fortune-tellers are referring to.Manichean is the 'tall, dark, handsome stranger' all the fortune-tellers are referring to.Manichean is the 'tall, dark, handsome stranger' all the fortune-tellers are referring to.Manichean is the 'tall, dark, handsome stranger' all the fortune-tellers are referring to.Manichean is the 'tall, dark, handsome stranger' all the fortune-tellers are referring to.Manichean is the 'tall, dark, handsome stranger' all the fortune-tellers are referring to.Manichean is the 'tall, dark, handsome stranger' all the fortune-tellers are referring to.
 
Manichean's Avatar
 
Posts: 3,130
Karma: 91256
Join Date: Feb 2008
Location: Germany
Device: Cybook Gen3
Quote:
Originally Posted by dkritso109 View Post
i have literaly thousands of books in that format, we are talking like a month's work of copy and pasting. i have gone over the tutorial with no avail.
I'm not talking about copying and pasting, I'm talking about the search & replace in bulk metadata editing. If you import your books with lastname, firstname in {authors} and then do a bulk metadata search & replace on {authors}, searching for
Code:
(.*?),\s(.*?)
and replacing it with
Code:
\2 \1
you should be fine. (Caution: I haven't tested that expression, but it should do the trick if the fields are the way I assumed in this post.)

Last edited by Manichean; 10-02-2010 at 04:25 PM. Reason: Stupid punctuation after a code block...
Manichean is offline   Reply With Quote
Old 10-02-2010, 04:28 PM   #8
kacir
Wizard
kacir ought to be getting tired of karma fortunes by now.kacir ought to be getting tired of karma fortunes by now.kacir ought to be getting tired of karma fortunes by now.kacir ought to be getting tired of karma fortunes by now.kacir ought to be getting tired of karma fortunes by now.kacir ought to be getting tired of karma fortunes by now.kacir ought to be getting tired of karma fortunes by now.kacir ought to be getting tired of karma fortunes by now.kacir ought to be getting tired of karma fortunes by now.kacir ought to be getting tired of karma fortunes by now.kacir ought to be getting tired of karma fortunes by now.
 
kacir's Avatar
 
Posts: 3,450
Karma: 10484861
Join Date: May 2006
Device: PocketBook 360, before it was Sony Reader, cassiopeia A-20
Quote:
Originally Posted by dkritso109 View Post
see my dilemma??? can anyone give me an expression that most closely extracts the relevant data i need into the metadata card?
At this very moment I do it this way:
- When I need to process a few books, I do it manually, with Drag & Drop of the book, then I press E and use icons next to title, name, author to swap some words.
- when I have many books to import, especially when they are just files with name of book in a directory that has author name, I make listing of all files (on Linux) it is like
Code:
cd ~/BooksToProcess
find . -type f > copybooks.sh
on Windows you would use something like dir /R/B > copybooks.bat

Then I open copybooks.sh in Gvim text editor and I massage it with Regular-Expresion-Fu until I get something like
Code:
cp '~/BooksToProcess/Armstrong, Kelley/Otherworld/ 1 - Bitten' '~/ImportTempDir/Kelley Armstrong - Otherworld 1 - Bitten'
then I import books into Calibre in bulk.

Another solution with the newest Calibre would be to import the books as they are, and then process Authors field using Regular Expressions with backreferences.
So:
Select books
Right click, select Bulk Edit Metadata
go to Search and Replace
select Search mode Regular Expressions
Search for ([^,]*), (.*)
Replace expression \2 \1
and, of course select Search Field and Destination Field "authors"

DO NOT FORGET TO MAKE BACKUP OF THE LIBRARY BEFORE ATTEMPTING SOMETHING LIKE THIS
kacir is offline   Reply With Quote
Old 10-02-2010, 04:32 PM   #9
Manichean
Wizard
Manichean is the 'tall, dark, handsome stranger' all the fortune-tellers are referring to.Manichean is the 'tall, dark, handsome stranger' all the fortune-tellers are referring to.Manichean is the 'tall, dark, handsome stranger' all the fortune-tellers are referring to.Manichean is the 'tall, dark, handsome stranger' all the fortune-tellers are referring to.Manichean is the 'tall, dark, handsome stranger' all the fortune-tellers are referring to.Manichean is the 'tall, dark, handsome stranger' all the fortune-tellers are referring to.Manichean is the 'tall, dark, handsome stranger' all the fortune-tellers are referring to.Manichean is the 'tall, dark, handsome stranger' all the fortune-tellers are referring to.Manichean is the 'tall, dark, handsome stranger' all the fortune-tellers are referring to.Manichean is the 'tall, dark, handsome stranger' all the fortune-tellers are referring to.Manichean is the 'tall, dark, handsome stranger' all the fortune-tellers are referring to.
 
Manichean's Avatar
 
Posts: 3,130
Karma: 91256
Join Date: Feb 2008
Location: Germany
Device: Cybook Gen3
Quote:
Originally Posted by kacir View Post
Another solution with the newest Calibre would be to import the books as they are, and then process Authors field using Regular Expressions with backreferences.
So:
Select books
Right click, select Bulk Edit Metadata
go to Search and Replace
select Search mode Regular Expressions
Search for ([^,]*), (.*)
Replace expression \2 \1
and, of course select Search Field and Destination Field "authors"
Your search expression is better than mine, I think... Although I used non-greedy quantifiers, it should be safer to exclude the comma.
Manichean is offline   Reply With Quote
Old 10-02-2010, 04:37 PM   #10
dkritso109
Enthusiast
dkritso109 began at the beginning.
 
Posts: 43
Karma: 10
Join Date: Jun 2010
Device: Kindle 3
wow, i think i'm gonna take a perl programming class at the local community college just so i can figure out a regular expression that works! or just pay a teenager minimum wage to go file by file and input them the way i want. don't know which way would be cheaper yet.
dkritso109 is offline   Reply With Quote
Old 10-02-2010, 04:40 PM   #11
Manichean
Wizard
Manichean is the 'tall, dark, handsome stranger' all the fortune-tellers are referring to.Manichean is the 'tall, dark, handsome stranger' all the fortune-tellers are referring to.Manichean is the 'tall, dark, handsome stranger' all the fortune-tellers are referring to.Manichean is the 'tall, dark, handsome stranger' all the fortune-tellers are referring to.Manichean is the 'tall, dark, handsome stranger' all the fortune-tellers are referring to.Manichean is the 'tall, dark, handsome stranger' all the fortune-tellers are referring to.Manichean is the 'tall, dark, handsome stranger' all the fortune-tellers are referring to.Manichean is the 'tall, dark, handsome stranger' all the fortune-tellers are referring to.Manichean is the 'tall, dark, handsome stranger' all the fortune-tellers are referring to.Manichean is the 'tall, dark, handsome stranger' all the fortune-tellers are referring to.Manichean is the 'tall, dark, handsome stranger' all the fortune-tellers are referring to.
 
Manichean's Avatar
 
Posts: 3,130
Karma: 91256
Join Date: Feb 2008
Location: Germany
Device: Cybook Gen3
Quote:
Originally Posted by dkritso109 View Post
wow, i think i'm gonna take a perl programming class at the local community college just so i can figure out a regular expression that works! or just pay a teenager minimum wage to go file by file and input them the way i want. don't know which way would be cheaper yet.
If you have to take a class, take a Python class, since Calibre is written in that language. Alternatively, go over the tutorial once again from the very beginning to the very end, and if that doesn't help, post where you're stuck, so we can try to help.
Manichean is offline   Reply With Quote
Old 10-02-2010, 04:47 PM   #12
dkritso109
Enthusiast
dkritso109 began at the beginning.
 
Posts: 43
Karma: 10
Join Date: Jun 2010
Device: Kindle 3
yeah you guys are awesome thanks, i been going over it for hours and hours now. i could've read a few books by now. will continue to try and i'll post back with an update. thanks again, also if anyone does figure it out hit me up.
dkritso109 is offline   Reply With Quote
Old 10-02-2010, 04:51 PM   #13
Manichean
Wizard
Manichean is the 'tall, dark, handsome stranger' all the fortune-tellers are referring to.Manichean is the 'tall, dark, handsome stranger' all the fortune-tellers are referring to.Manichean is the 'tall, dark, handsome stranger' all the fortune-tellers are referring to.Manichean is the 'tall, dark, handsome stranger' all the fortune-tellers are referring to.Manichean is the 'tall, dark, handsome stranger' all the fortune-tellers are referring to.Manichean is the 'tall, dark, handsome stranger' all the fortune-tellers are referring to.Manichean is the 'tall, dark, handsome stranger' all the fortune-tellers are referring to.Manichean is the 'tall, dark, handsome stranger' all the fortune-tellers are referring to.Manichean is the 'tall, dark, handsome stranger' all the fortune-tellers are referring to.Manichean is the 'tall, dark, handsome stranger' all the fortune-tellers are referring to.Manichean is the 'tall, dark, handsome stranger' all the fortune-tellers are referring to.
 
Manichean's Avatar
 
Posts: 3,130
Karma: 91256
Join Date: Feb 2008
Location: Germany
Device: Cybook Gen3
Quote:
Originally Posted by dkritso109 View Post
yeah you guys are awesome thanks, i been going over it for hours and hours now. i could've read a few books by now. will continue to try and i'll post back with an update. thanks again, also if anyone does figure it out hit me up.
Wait, "if anyone does figure it out"? Both kacir and myself posted solutions to this. I don't think there's anything left to figure out.
Manichean is offline   Reply With Quote
Old 10-02-2010, 05:01 PM   #14
dkritso109
Enthusiast
dkritso109 began at the beginning.
 
Posts: 43
Karma: 10
Join Date: Jun 2010
Device: Kindle 3
i still can't get the author to load from FN,LN to LN,FN. from what i have gathered i have to go back and redo them with search and replace correct? that is where i am still lost.
dkritso109 is offline   Reply With Quote
Old 10-02-2010, 05:04 PM   #15
chaley
Grand Sorcerer
chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.
 
Posts: 11,734
Karma: 6690881
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Quote:
Originally Posted by Manichean View Post
Wait, "if anyone does figure it out"? Both kacir and myself posted solutions to this. I don't think there's anything left to figure out.
Maybe you should volunteer to be his teenager.
chaley is offline   Reply With Quote
Reply


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Regular Expression Help Azhad Calibre 86 09-27-2011 02:37 PM
Regular Expression Help smartmart Calibre 5 10-17-2010 05:19 AM
Sigil 024 and regular expressions on "all HTML files" WS64 Sigil 4 08-13-2010 07:33 PM
Help with the regular expression Dysonco Calibre 9 03-22-2010 10:45 PM
Help: Is there a search expression for "books without Series"? LARdT Calibre 3 01-20-2010 09:34 PM


All times are GMT -4. The time now is 12:11 PM.


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