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 08-16-2010, 03:49 AM   #1
Worm
Junior Member
Worm began at the beginning.
 
Worm's Avatar
 
Posts: 3
Karma: 10
Join Date: Aug 2010
Device: Nuvi
Need Help Creating a Regular Expression

Please forgive my level of competency here, but I have tried and tried and am lost. I am attempting to import my years-old collection of .pdf e-books and need to create a Regular Expression so that Calibre will properly import and map fields. I have about 3,000 e-books in the following format:

Star Wars - [Boba Fett 01] - The Fight to Survive (by Terry Bisson).pdf

The Output I would like in Calibre would be:

Book Title:
The Fight to Survive

Author:
Terry Bisson

Series:
Star Wars - Boba Fett

and then the #1 for the sequence in the series.


Is this possible via a Regular Expression?

Worm is offline   Reply With Quote
Old 08-16-2010, 07:53 AM   #2
Manichean
Wizard
Manichean My eyes! My eyes! The light is just too bright!Manichean My eyes! My eyes! The light is just too bright!Manichean My eyes! My eyes! The light is just too bright!Manichean My eyes! My eyes! The light is just too bright!Manichean My eyes! My eyes! The light is just too bright!Manichean My eyes! My eyes! The light is just too bright!Manichean My eyes! My eyes! The light is just too bright!Manichean My eyes! My eyes! The light is just too bright!Manichean My eyes! My eyes! The light is just too bright!Manichean My eyes! My eyes! The light is just too bright!Manichean My eyes! My eyes! The light is just too bright!
 
Manichean's Avatar
 
Posts: 3,130
Karma: 80520
Join Date: Feb 2008
Location: Germany
Device: Cybook Gen3
Should be possible. Take a look at the preferences, specifically the add/save books- page, which links to a handy reference for regular expressions as well as offering a test input thingy. You should be good from there.
Manichean is offline   Reply With Quote
 
Advertisement
Old 08-16-2010, 09:02 AM   #3
chaley
"chaley", not "charley"
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: 5,907
Karma: 1217216
Join Date: Jan 2010
Location: France
Device: Many android devices
I can get close, but not perfect.

Testing using the file name you supplied
Code:
Star Wars - [Boba Fett 01] - The Fight to Survive (by Terry Bisson).pdf
and assuming that *all* the files have this format, even if they do not have series, then the regular expression
Code:
(?P<series>(.+?))(?P<series_index>\d+)\] - (?P<title>.+) \(by (?P<author>.+)\)
almost works. The problem comes from the '[' and ']' characters. The series name should be the first characters up to the 2 digits followed by the ']', with the '[' removed ('Star Wars - Boba Fett'). Unfortunately, there is no way (that I know of) to remove characters within a regular expression group, so you are stuck with generating series names like 'Star Wars - [Boba Fett'.

I see two ways to deal with the extra '['. The first is to rename the files before importing to calibre. I would generate a text file containing all the book names, then edit that file to create a batch/shell script to rename the books. stripping away the leading '['.

If the batch operation isn't something you want to try, then I would run the import, then use the 'manage series' dialog available from the tag browser to manually remove the '[' character from each series. Manually correcting the series this way shouldn't take too long, around 1 to 2 seconds per series.

See the attached screenshot to see the regexp in action.
Attached Thumbnails
Click image for larger version

Name:	re.jpg
Views:	117
Size:	44.0 KB
ID:	56738  
chaley is offline   Reply With Quote
Old 08-16-2010, 12:41 PM   #4
Worm
Junior Member
Worm began at the beginning.
 
Worm's Avatar
 
Posts: 3
Karma: 10
Join Date: Aug 2010
Device: Nuvi
Brilliant and my most sincere thanks! I will try this after work today.
Worm is offline   Reply With Quote
Old 08-16-2010, 03:38 PM   #5
EricLandes
Connoisseur
EricLandes can illuminate an eclipseEricLandes can illuminate an eclipseEricLandes can illuminate an eclipseEricLandes can illuminate an eclipseEricLandes can illuminate an eclipseEricLandes can illuminate an eclipseEricLandes can illuminate an eclipseEricLandes can illuminate an eclipseEricLandes can illuminate an eclipseEricLandes can illuminate an eclipseEricLandes can illuminate an eclipse
 
Posts: 95
Karma: 8282
Join Date: Jan 2010
Device: Kindle PW, Kobo Aura HD, Galaxy Note 10.1
If you want to do a lot of batch file-renaming before importing into Calibre, look long and hard at the Name It Your Own Way tool.

That tool has saved me hours of time.
EricLandes is offline   Reply With Quote
Old 08-16-2010, 03:57 PM   #6
chaley
"chaley", not "charley"
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: 5,907
Karma: 1217216
Join Date: Jan 2010
Location: France
Device: Many android devices
Quote:
Originally Posted by EricLandes View Post
If you want to do a lot of batch file-renaming before importing into Calibre, look long and hard at the Name It Your Own Way tool.

That tool has saved me hours of time.
Thanks. I like the regular expression matching. Saves me from having to use vim to create batch files.

The tool is at http://www.niyow.com/.
chaley is offline   Reply With Quote
Old 08-17-2010, 01:57 AM   #7
Worm
Junior Member
Worm began at the beginning.
 
Worm's Avatar
 
Posts: 3
Karma: 10
Join Date: Aug 2010
Device: Nuvi
Thumbs up

I'm on a Mac so Terminal is great so long as I get the commands right. Else, this is a great GUI on OSX: http://manytricks.com/namemangler/.

Those Regular Expressions worked perfectly for my files, by the way. Thank you again!
Worm is offline   Reply With Quote
Old 08-17-2010, 10:31 AM   #8
edbro
Warthog Driver
edbro is fluent in JavaScript as well as Klingon.edbro is fluent in JavaScript as well as Klingon.edbro is fluent in JavaScript as well as Klingon.edbro is fluent in JavaScript as well as Klingon.edbro is fluent in JavaScript as well as Klingon.edbro is fluent in JavaScript as well as Klingon.edbro is fluent in JavaScript as well as Klingon.edbro is fluent in JavaScript as well as Klingon.edbro is fluent in JavaScript as well as Klingon.edbro is fluent in JavaScript as well as Klingon.edbro is fluent in JavaScript as well as Klingon.
 
edbro's Avatar
 
Posts: 632
Karma: 4911
Join Date: Jul 2007
Location: Grapevine, TX
Device: iPad4
Quote:
Originally Posted by chaley View Post
Thanks. I like the regular expression matching. Saves me from having to use vim to create batch files.

The tool is at http://www.niyow.com/.
How much is it?

I hate software that will not tell you how much it costs unless you install it on your PC. I see no link on the site where you can see the cost or buy it. They don't even tell you it is shareware but I inferred it by the "download free" label.
edbro is offline   Reply With Quote
Old 08-17-2010, 10:41 AM   #9
chaley
"chaley", not "charley"
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: 5,907
Karma: 1217216
Join Date: Jan 2010
Location: France
Device: Many android devices
Quote:
Originally Posted by edbro View Post
How much is it?
The news section of the website says that it is freeware.

The license agreement (included in the spoiler) says that same thing.
Spoiler:

General Issues

* This is a free software.

Distribution

You are not allowed to attempt to reverse engineer, disassemble or
decompile this software in any way!
You are specifically prohibited from charging, or requesting donations,
for any such copies, however made; and from distributing the software
and/or documentation with other products (commercial or otherwise)
without prior written permission.

Disclaimer of Warranty

THIS SOFTWARE AND THE ACCOMPANYING FILES ARE SOLD 'AS IS' AND
WITHOUT WARRANTIES AS TO PERFORMANCE OR MERCHANTABILITY
OR ANY OTHER WARRANTIES WHETHER EXPRESSED OR IMPLIED.
Because of the various hardware and software environments into which this
software may be put, NO WARRANTY OF FITNESS FOR A PARTICULAR
PURPOSE IS OFFERED.

Good data processing procedure dictates that any program be thoroughly
tested with non-critical data before relying on it. The user must assume the
entire risk of using the program. ANY LIABILITY OF THE SELLER WILL BE
LIMITED EXCLUSIVELY TO PRODUCT REPLACEMENT OR REFUND OF
PURCHASE PRICE.
chaley is offline   Reply With Quote
Old 08-18-2010, 02:20 PM   #10
plunderydoo
Enthusiast
plunderydoo has a complete set of Star Wars action figures.plunderydoo has a complete set of Star Wars action figures.plunderydoo has a complete set of Star Wars action figures.plunderydoo has a complete set of Star Wars action figures.plunderydoo has a complete set of Star Wars action figures.
 
Posts: 38
Karma: 412
Join Date: Sep 2009
Device: WinMobile, Hanvon N516 w. OpenInkPot, eLyricon EBX-500, Iphone 3GS
try this Tool for renaming:
http://www.joejoesoft.com/cms/showpage.php?cid=108

It can do regex and is extremly flexible - and its free.
plunderydoo is offline   Reply With Quote
Reply

Tags
import, regular expression

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Regular Expression Help Azhad Calibre 86 09-27-2011 03:37 PM
Regular Expression Help smartmart Calibre 5 10-17-2010 06:19 AM
Help!! Having trouble with regular expression Partzz Calibre 2 09-14-2010 01:32 PM
Regular Expression Help Needed dloyer4 Calibre 1 07-25-2010 11:37 PM
Help with the regular expression Dysonco Calibre 9 03-22-2010 11:45 PM


All times are GMT -4. The time now is 10:25 PM.


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