![]() |
#1 |
Junior Member
![]() 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>.+) |
![]() |
![]() |
![]() |
#2 |
Ex-Helpdesk Junkie
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() 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.
|
![]() |
![]() |
Advert | |
|
![]() |
#3 |
Junior Member
![]() 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/_/--}"' |
![]() |
![]() |
![]() |
#4 |
Ex-Helpdesk Junkie
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() 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 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. |
![]() |
![]() |
![]() |
#5 |
Junior Member
![]() 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.
![]() |
![]() |
![]() |
Advert | |
|
![]() |
#6 |
Junior Member
![]() 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 |
![]() |
![]() |
![]() |
#7 |
Ex-Helpdesk Junkie
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() 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.
|
![]() |
![]() |
![]() |
#8 |
Junior Member
![]() Posts: 6
Karma: 10
Join Date: Aug 2015
Device: none
|
![]() |
![]() |
![]() |
![]() |
#9 | |
Fanatic
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 515
Karma: 1470724
Join Date: Jul 2013
Location: Quebec CA
Device: android 4 (samsung tablet and asus tablet)
|
Quote:
|
|
![]() |
![]() |
![]() |
#10 |
Ex-Helpdesk Junkie
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() 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.
![]() ![]() |
![]() |
![]() |
![]() |
#11 |
Junior Member
![]() 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.
|
![]() |
![]() |
![]() |
|
![]() |
||||
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 |