Register Guidelines E-Books Today's Posts Search

Go Back   MobileRead Forums > E-Book Software > Calibre > Library Management

Notices

Reply
 
Thread Tools Search this Thread
Old 08-13-2015, 11:28 AM   #1
nvcleemp
Junior Member
nvcleemp began at the beginning.
 
Posts: 6
Karma: 10
Join Date: Aug 2015
Device: none
Regexp for adding books failing

I'm adding a couple of hundred books which all use the following naming scheme:

name of authors_Title of book.pdf

I tried this regular expression, but for some reason everything gets thrown into title and authors is Unknown:

(?P<author>[^_]+)_(?P<title>.+)
nvcleemp is offline   Reply With Quote
Old 08-13-2015, 11:48 AM   #2
eschwartz
Ex-Helpdesk Junkie
eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.
 
eschwartz's Avatar
 
Posts: 19,421
Karma: 85400180
Join Date: Nov 2012
Location: The Beaten Path, USA, Roundworld, This Side of Infinity
Device: Kindle Touch fw5.3.7 (Wifi only)
The underscore is being replaced with a space before the matching happens. I would suggest renaming all your files to use " - " as a separator.
eschwartz is offline   Reply With Quote
Advert
Old 08-13-2015, 12:06 PM   #3
nvcleemp
Junior Member
nvcleemp began at the beginning.
 
Posts: 6
Karma: 10
Join Date: Aug 2015
Device: none
Ok, thanks. Maybe I should have been able to figure that one out myself. ;-)

I've replaced the underscore by -- since - might occur in the name sometimes. This is what I used to rename the files:

find . -name '*_*' -exec bash -c 'mv "$0" "${0/_/--}"'
nvcleemp is offline   Reply With Quote
Old 08-13-2015, 12:26 PM   #4
eschwartz
Ex-Helpdesk Junkie
eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.
 
eschwartz's Avatar
 
Posts: 19,421
Karma: 85400180
Join Date: Nov 2012
Location: The Beaten Path, USA, Roundworld, This Side of Infinity
Device: Kindle Touch fw5.3.7 (Wifi only)
It did say something about that in the calibre description but it wasn't clear if that was before or after the regex.

for the renaming -- that would be easier than some of those Windows file mangling tools. (I hate having to tell Windows users to hunt one of those down and do something I don't know with it.)


But you don't need to exec bash unless you specifically want to override your current shell. Just use:
Code:
find . -name '*_*' -exec mv "$0" "${0/_/--}"

Last edited by eschwartz; 08-13-2015 at 12:29 PM.
eschwartz is offline   Reply With Quote
Old 08-13-2015, 12:53 PM   #5
nvcleemp
Junior Member
nvcleemp began at the beginning.
 
Posts: 6
Karma: 10
Join Date: Aug 2015
Device: none
Thanks, I usually manage on the shell, but my solutions aren't always the prettiest.
nvcleemp is offline   Reply With Quote
Advert
Old 08-17-2015, 01:36 AM   #6
nvcleemp
Junior Member
nvcleemp began at the beginning.
 
Posts: 6
Karma: 10
Join Date: Aug 2015
Device: none
OK, I thought I had solved it, but for some reason I started Calibre up today and wanted to check the regexp before adding the next folder, but again everything ends up in the Title field.

This is the regexp: (?P<author>.+)--(?P<title>.+) \((?P<publisher>.+) (?P<published>[0-9])\)

This is the test file name: Agaian S.S.--Hadamard Matrices and Their Applications (Springer 1985).pdf
nvcleemp is offline   Reply With Quote
Old 08-17-2015, 01:47 AM   #7
eschwartz
Ex-Helpdesk Junkie
eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.
 
eschwartz's Avatar
 
Posts: 19,421
Karma: 85400180
Join Date: Nov 2012
Location: The Beaten Path, USA, Roundworld, This Side of Infinity
Device: Kindle Touch fw5.3.7 (Wifi only)
Psst. You forgot to repeat the 0-9 character set for the year.
eschwartz is offline   Reply With Quote
Old 08-18-2015, 03:04 AM   #8
nvcleemp
Junior Member
nvcleemp began at the beginning.
 
Posts: 6
Karma: 10
Join Date: Aug 2015
Device: none
nvcleemp is offline   Reply With Quote
Old 08-25-2015, 09:54 AM   #9
LadyKate
Fanatic
LadyKate ought to be getting tired of karma fortunes by now.LadyKate ought to be getting tired of karma fortunes by now.LadyKate ought to be getting tired of karma fortunes by now.LadyKate ought to be getting tired of karma fortunes by now.LadyKate ought to be getting tired of karma fortunes by now.LadyKate ought to be getting tired of karma fortunes by now.LadyKate ought to be getting tired of karma fortunes by now.LadyKate ought to be getting tired of karma fortunes by now.LadyKate ought to be getting tired of karma fortunes by now.LadyKate ought to be getting tired of karma fortunes by now.LadyKate ought to be getting tired of karma fortunes by now.
 
Posts: 515
Karma: 1470724
Join Date: Jul 2013
Location: Quebec CA
Device: android 4 (samsung tablet and asus tablet)
Quote:
Originally Posted by nvcleemp View Post
OK, I thought I had solved it, but for some reason I started Calibre up today and wanted to check the regexp before adding the next folder, but again everything ends up in the Title field.

This is the regexp: (?P<author>.+)--(?P<title>.+) \((?P<publisher>.+) (?P<published>[0-9])\)

This is the test file name: Agaian S.S.--Hadamard Matrices and Their Applications (Springer 1985).pdf
Doesn't the . need to be escaped? I thought the regex would see the . as an "all".
LadyKate is offline   Reply With Quote
Old 08-25-2015, 01:37 PM   #10
eschwartz
Ex-Helpdesk Junkie
eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.
 
eschwartz's Avatar
 
Posts: 19,421
Karma: 85400180
Join Date: Nov 2012
Location: The Beaten Path, USA, Roundworld, This Side of Infinity
Device: Kindle Touch fw5.3.7 (Wifi only)
It is supposed to do that. How else do you... match a long string?
eschwartz is offline   Reply With Quote
Old 08-29-2015, 02:23 AM   #11
nvcleemp
Junior Member
nvcleemp began at the beginning.
 
Posts: 6
Karma: 10
Join Date: Aug 2015
Device: none
Indeed, the . matches the whole author's name, and not just the . at the end of the name. The -- matches the separator and the . then collects everything in front of it.
nvcleemp is offline   Reply With Quote
Reply


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Regexp help for saving books Phssthpok Library Management 3 06-24-2015 11:31 AM
Need help with RegExp theichens Calibre 1 02-09-2013 08:40 AM
Calibre now failing to convert Kindle books stripeycat Conversion 2 01-11-2013 03:35 PM
Calibre is failing to email books to my kindle.com address coxwalls Devices 4 11-25-2012 10:45 AM
Regexp for series in books library noimporta Library Management 14 05-05-2011 08:20 AM


All times are GMT -4. The time now is 06:00 PM.


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