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 06-12-2011, 08:32 AM   #1
genright
Junior Member
genright began at the beginning.
 
Posts: 8
Karma: 10
Join Date: Jun 2011
Device: laptop mostly, or any other handy screen
Adding books with series in the filename

Can anyone please help with a regex for adding books that may optionally have a series? I have one that gets a trailing title correctly most of the tme, but series get lumped with the author name.

eg "bob smith - a long series 01 - my title.txt"

I tried variations on the below but that fails, and google doesnt seem to help.

(?P<author>.+)( - (?P<series> <series_index>))? - (?P<title>[^_]+)

Cheers for any suggestions

Last edited by genright; 06-12-2011 at 09:07 AM.
genright is offline   Reply With Quote
Old 06-12-2011, 08:46 AM   #2
genright
Junior Member
genright began at the beginning.
 
Posts: 8
Karma: 10
Join Date: Jun 2011
Device: laptop mostly, or any other handy screen
Another example, this works but breaks for files that do not have a series such as "bob smith - another title.txt". Also, how can I grab the series index as well?

(?P<author>.+) - (?P<series>.+)? - (?P<title>[^_]+)

Last edited by genright; 06-12-2011 at 09:09 AM.
genright is offline   Reply With Quote
Advert
Old 06-12-2011, 10:57 AM   #3
penguinaka
Quack! Quack!
penguinaka can eat soup with a fork.penguinaka can eat soup with a fork.penguinaka can eat soup with a fork.penguinaka can eat soup with a fork.penguinaka can eat soup with a fork.penguinaka can eat soup with a fork.penguinaka can eat soup with a fork.penguinaka can eat soup with a fork.penguinaka can eat soup with a fork.penguinaka can eat soup with a fork.penguinaka can eat soup with a fork.
 
penguinaka's Avatar
 
Posts: 92
Karma: 9176
Join Date: Apr 2011
Location: Florida
Device: kindle 3 & sony daily prs950sc
^(?P<author>[^-]+)(\s*-\s*(\[?(?P<series>[^-0-9]+)\s*(?P<series_index>[0-9.]+)?]?)?)?.*?-\s*(?P<title>[^\]{[()]+\w)

this one removes all brackets around the series and anything in brackets in the title section doesn't get imported imported


^(?P<author>[^-]+)(\s*-\s*(\[?(?P<series>[^-0-9]+)\s*(?P<series_index>[0-9.]+)?]?)?)?.*?-\s*(?P<title>[^-]+)

this one removes brackets around the series section but leaves things in brackets in the title so you get version information imported with the title


*note - i find it useful to do some file clean up prior to import with a bulk renaming software.

There are 2 that are very good with Flash Renamer being my favorite the other is called Bulk Rename Utility. In these you can enter regex commands in the find and replace to clean up files or wildcards if you don't know how to use regex.

Two other tools I use is ExtractNow which auto extract & deletes archives after extraction in folders and folders of folders without having to manually go there and Opus which replaces windows explorer with a comander style split screen and a view screen so you can inspect whats in any type of file without opening them it also allows you to make customized regex, find & replace rename and other stuff as buttons and place them on the menu bar.

Some of the button I have created and added to the bar on Opus... for example I have a swap author and title button; swap ln, fn button; swap author, series, title button (in any combination); replace by with -; swap ln,fn & ln,fn button; and trim all double spaces and trailing space; and some others.

I use flash renamer first because you can string together a bunch of commands to do in a batch command to run against your files in bulk. The any minor quick fixes i do with buttons from opus when i reinspect to make sure everything is like i like it. Cheers i hope that helps.

Last edited by penguinaka; 06-12-2011 at 02:42 PM.
penguinaka is offline   Reply With Quote
Old 06-12-2011, 12:35 PM   #4
Manichean
Wizard
Manichean is the 'tall, dark, handsome stranger' all the fortune-tellers are referring to.Manichean is the 'tall, dark, handsome stranger' all the fortune-tellers are referring to.Manichean is the 'tall, dark, handsome stranger' all the fortune-tellers are referring to.Manichean is the 'tall, dark, handsome stranger' all the fortune-tellers are referring to.Manichean is the 'tall, dark, handsome stranger' all the fortune-tellers are referring to.Manichean is the 'tall, dark, handsome stranger' all the fortune-tellers are referring to.Manichean is the 'tall, dark, handsome stranger' all the fortune-tellers are referring to.Manichean is the 'tall, dark, handsome stranger' all the fortune-tellers are referring to.Manichean is the 'tall, dark, handsome stranger' all the fortune-tellers are referring to.Manichean is the 'tall, dark, handsome stranger' all the fortune-tellers are referring to.Manichean is the 'tall, dark, handsome stranger' all the fortune-tellers are referring to.
 
Manichean's Avatar
 
Posts: 3,130
Karma: 91256
Join Date: Feb 2008
Location: Germany
Device: Cybook Gen3
Quote:
Originally Posted by genright View Post
(?P<author>.+)( - (?P<series> <series_index>))? - (?P<title>[^_]+)
The problem is the series field. You're using named backreferences wrong, try taking a look at the tutorial.
You'll probably want to use something like
Code:
(?P<author>.+)( - (?P<series>[^0-9]+) (?P<series_index>\d+))? - (?P<title>[^_]+)
or something similar.
Manichean is offline   Reply With Quote
Old 06-12-2011, 10:58 PM   #5
genright
Junior Member
genright began at the beginning.
 
Posts: 8
Karma: 10
Join Date: Jun 2011
Device: laptop mostly, or any other handy screen
Quote:
Originally Posted by penguinaka View Post


^(?P<author>[^-]+)(\s*-\s*(\[?(?P<series>[^-0-9]+)\s*(?P<series_index>[0-9.]+)?]?)?)?.*?-\s*(?P<title>[^-]+)

this one removes brackets around the series section but leaves things in brackets in the title so you get version information imported with the title
Nice one! This wors especailly well with the cases I have, many thanks. I'm still working through how it functions, but likely would never have tried so many nested expresions else. Your other suggestions are also duly noted. I've also used krename from the kde app suite in the past.

@Manichean: Thanks for the tip, I had read through that doc but didnt feel the enlightement yet. In hindsight my first attempts were indeed so flawed

Really appreciate the quick feedback guys. Caliber is awesome
genright is offline   Reply With Quote
Advert
Old 06-13-2011, 03:20 PM   #6
penguinaka
Quack! Quack!
penguinaka can eat soup with a fork.penguinaka can eat soup with a fork.penguinaka can eat soup with a fork.penguinaka can eat soup with a fork.penguinaka can eat soup with a fork.penguinaka can eat soup with a fork.penguinaka can eat soup with a fork.penguinaka can eat soup with a fork.penguinaka can eat soup with a fork.penguinaka can eat soup with a fork.penguinaka can eat soup with a fork.
 
penguinaka's Avatar
 
Posts: 92
Karma: 9176
Join Date: Apr 2011
Location: Florida
Device: kindle 3 & sony daily prs950sc
Thanks glad it helps. I took a look at krename because i'm always after a more powerful tool but from what little i tested it i find that flash renamer covers a lot more ground and seems to be easier to use.
penguinaka is offline   Reply With Quote
Reply


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
[Old Thread] Adding new column to sort by filename ShinRa Actual Library Management 20 02-12-2012 10:22 AM
Assistance with adding series titles/number - Calibre 0.8.2/Nook Classic Galora Library Management 0 05-25-2011 10:50 AM
Adding book series to cover??? artemisblossom Calibre 4 09-14-2010 05:31 PM
Adding Series and Number to Title. Cerepol Calibre 17 09-01-2010 06:50 PM
Pet peeve: series authors who introduce things in non-series books! ficbot Reading Recommendations 12 02-06-2010 02:14 AM


All times are GMT -4. The time now is 03:52 PM.


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