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 09-23-2014, 10:48 PM   #1
kite
enturbulated
kite can tell if an avocado is ripe without touching it.kite can tell if an avocado is ripe without touching it.kite can tell if an avocado is ripe without touching it.kite can tell if an avocado is ripe without touching it.kite can tell if an avocado is ripe without touching it.kite can tell if an avocado is ripe without touching it.kite can tell if an avocado is ripe without touching it.kite can tell if an avocado is ripe without touching it.kite can tell if an avocado is ripe without touching it.kite can tell if an avocado is ripe without touching it.kite can tell if an avocado is ripe without touching it.
 
kite's Avatar
 
Posts: 30
Karma: 130494
Join Date: May 2007
Device: Kobo Aura HD
regex for filename with muliple dots? (adding books)

SOLVED Trying to get a regex for filename with variable number of dots (<2).

I get the following from the tutorial and other threads, (thanks to Starson17 for all your generous contributions):
Untick, "Read metadata from file contents rather than file name"
and the regular expression
Firstauthorname SurnameAuthor - Title.pdf
works with
(?P<author>[^_]+) - (?P<title>.+)
while
Firstauthorname SurnameAuthor. Title.pdf
works with
(?P<author>[^_]+)\. (?P<title>.+)

However
Firstauthorname SurnameAuthor. Title A. Title B. Title C. Title D. Volume 2..pdf
doesn't work with anything I can find.

I want everything between the first "dot white space" and ".pdf" to be read as the title.

Real life example of file name:
Dionysius of Halicarnassus. Roman Antiquities, IV. Books VI.49-VII.pdf

How do I modify
(?P<author>[^_]+)\. (?P<title>.+)
so it ignores special characters after the first dot?

Last edited by kite; 09-28-2014 at 09:13 AM. Reason: problem solved
kite is offline   Reply With Quote
Old 09-23-2014, 11:00 PM   #2
susan_cassidy
Wizard
susan_cassidy ought to be getting tired of karma fortunes by now.susan_cassidy ought to be getting tired of karma fortunes by now.susan_cassidy ought to be getting tired of karma fortunes by now.susan_cassidy ought to be getting tired of karma fortunes by now.susan_cassidy ought to be getting tired of karma fortunes by now.susan_cassidy ought to be getting tired of karma fortunes by now.susan_cassidy ought to be getting tired of karma fortunes by now.susan_cassidy ought to be getting tired of karma fortunes by now.susan_cassidy ought to be getting tired of karma fortunes by now.susan_cassidy ought to be getting tired of karma fortunes by now.susan_cassidy ought to be getting tired of karma fortunes by now.
 
Posts: 2,251
Karma: 3720310
Join Date: Jan 2009
Location: USA
Device: Kindle, iPad (not used much for reading)
You normally have to escape a period in a regex. Like this: \.. Otherwise it means any character.
susan_cassidy is offline   Reply With Quote
Advert
Old 09-24-2014, 04:38 AM   #3
kite
enturbulated
kite can tell if an avocado is ripe without touching it.kite can tell if an avocado is ripe without touching it.kite can tell if an avocado is ripe without touching it.kite can tell if an avocado is ripe without touching it.kite can tell if an avocado is ripe without touching it.kite can tell if an avocado is ripe without touching it.kite can tell if an avocado is ripe without touching it.kite can tell if an avocado is ripe without touching it.kite can tell if an avocado is ripe without touching it.kite can tell if an avocado is ripe without touching it.kite can tell if an avocado is ripe without touching it.
 
kite's Avatar
 
Posts: 30
Karma: 130494
Join Date: May 2007
Device: Kobo Aura HD
Further experimenting reveals that it is not the "." dots that are the problem.
Filename: Agog Delm. Try This........WouldYou..FDasdf...pdf
gives;
Title: Try This........WouldYou..FDasdf..
Author: Agog Delm
Just as I want.

Edited: But any more dots next to spaces (after the first ". space" following the title) messes things up.

Last edited by kite; 09-25-2014 at 12:29 AM. Reason: repair inaccurate description
kite is offline   Reply With Quote
Old 09-25-2014, 03:26 PM   #4
JustForFun
Enthusiast
JustForFun has learned how to read e-booksJustForFun has learned how to read e-booksJustForFun has learned how to read e-booksJustForFun has learned how to read e-booksJustForFun has learned how to read e-booksJustForFun has learned how to read e-booksJustForFun has learned how to read e-books
 
Posts: 30
Karma: 752
Join Date: Nov 2010
Device: PB360
Does (?P<author>.+?)\. (?P<title>.+) work for you? It considers all characters before the first dot followed by a space as author and the rest as title.

Regexes are greedy by default which means that (?P<author>[^_]+)\. matches all characters (which are not '_') before the last dot followed by a space as author. See the note under Hey, neat! This is starting to make sense! in the tutorial on regexes.
JustForFun is offline   Reply With Quote
Old 09-25-2014, 05:37 PM   #5
BetterRed
null operator (he/him)
BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.
 
Posts: 20,565
Karma: 26954694
Join Date: Mar 2012
Location: Sydney Australia
Device: none
I would fix the file names to match the pattern I have selected in the Add Books config.

File renamers are a dime a dozen, some have regex facilities, almost all feature a preview and many have an exclude.

If I wanted to retain the existing filenames, I would create hardlinks, rename and add them to calibre and then trash 'em.

BR
BetterRed is online now   Reply With Quote
Advert
Old 09-28-2014, 09:09 AM   #6
kite
enturbulated
kite can tell if an avocado is ripe without touching it.kite can tell if an avocado is ripe without touching it.kite can tell if an avocado is ripe without touching it.kite can tell if an avocado is ripe without touching it.kite can tell if an avocado is ripe without touching it.kite can tell if an avocado is ripe without touching it.kite can tell if an avocado is ripe without touching it.kite can tell if an avocado is ripe without touching it.kite can tell if an avocado is ripe without touching it.kite can tell if an avocado is ripe without touching it.kite can tell if an avocado is ripe without touching it.
 
kite's Avatar
 
Posts: 30
Karma: 130494
Join Date: May 2007
Device: Kobo Aura HD
Quote:
Originally Posted by JustForFun View Post
Does (?P<author>.+?)\. (?P<title>.+) work for you? It considers all characters before the first dot followed by a space as author and the rest as title.
...

Thanks for your help people.

(?P<author>.+?)\. (?P<title>.+) does the trick nicely.

And having read "Hey neat ... " for the fifth time has me thinking that I could have made the + in the first phrase of (?P<author>[^_]+)\. (?P<title>.+) non-greedy by adding a ? just so (?P<author>[^_]+?)\. (?P<title>.+)

"Regexes are greedy by default which means that (?P<author>[^_]+)\. matches all characters (which are not '_') before the last dot followed by a space as author."
I had tried many combinations and permutations but all in the second phrase of the expression as I ASSumed that the first phrase stopped matching at the first "\. "

My grasp of regular expressions doesn't let me create and use them in Bulk File Rename yet.
kite is offline   Reply With Quote
Reply

Tags
adding books, regex


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Adding books - regex help tonyx3 Library Management 1 03-13-2013 08:21 AM
Adding books with different filename structures Sinnott Library Management 2 11-09-2012 08:12 AM
Adding books with series in the filename genright Library Management 5 06-13-2011 03:20 PM
RegEx - filename metadata help ejjenkins Calibre 4 12-28-2010 05:47 PM
A little help adding books and using regex. Dragonator Calibre 7 12-17-2010 06:57 PM


All times are GMT -4. The time now is 12:23 AM.


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