|
|
#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.
|
|
|
|
|
|
#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 it wasn't clear if that was before or after the regex. (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 01: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.
|
|
|
|
|
|
#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.
How else do you... match a long string?
|
|
|
|
|
|
#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.
|
|
|
|
![]() |
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Regexp help for saving books | Phssthpok | Library Management | 3 | 06-24-2015 12:31 PM |
| Need help with RegExp | theichens | Calibre | 1 | 02-09-2013 09:40 AM |
| Calibre now failing to convert Kindle books | stripeycat | Conversion | 2 | 01-11-2013 04:35 PM |
| Calibre is failing to email books to my kindle.com address | coxwalls | Devices | 4 | 11-25-2012 11:45 AM |
| Regexp for series in books library | noimporta | Library Management | 14 | 05-05-2011 09:20 AM |