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 02-02-2015, 12:59 PM   #1
xd1986k
Member
xd1986k began at the beginning.
 
xd1986k's Avatar
 
Posts: 10
Karma: 10
Join Date: Dec 2014
Device: Kindle Fire HDX 7, Ipad
Regex in importing help.

Hello.
I have a bunch of files on my desktop that I'd like to import without a ton of manual metadata editing. I noticed the Regular Expression import from filename. I'm gonna get around to regex one of these days but in the meantime I'd be grateful if someone helped me.
My files on hard disk are arranged as such.
[Novel] The Top (Nein) 01 -e-
I need to import them in the following format.
Title=The Top 01
Series=The Top [01]
Alternate Title(Self Made Field)=Nein
Status(Self Made Field)=-e-
Thanks for the help.
xd1986k is offline   Reply With Quote
Old 02-02-2015, 09:12 PM   #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,422
Karma: 85397180
Join Date: Nov 2012
Location: The Beaten Path, USA, Roundworld, This Side of Infinity
Device: Kindle Touch fw5.3.7 (Wifi only)
You can't put part of the filename into two different fields.
Also, you cannot use custom columns in the adding regex.
eschwartz is offline   Reply With Quote
Advert
Old 02-02-2015, 09:33 PM   #3
theducks
Well trained by Cats
theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.
 
theducks's Avatar
 
Posts: 29,817
Karma: 54830978
Join Date: Aug 2009
Location: The Central Coast of California
Device: Kobo Libra2,Kobo Aura2v1, K4NT(Fixed: New Bat.), Galaxy Tab A
Quote:
Originally Posted by eschwartz View Post
You can't put part of the filename into two different fields.
Also, you cannot use custom columns in the adding regex.
Bulk Metadata edit Search and Replace can copy to any field (of the correct type)
theducks is offline   Reply With Quote
Old 02-02-2015, 09:54 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,422
Karma: 85397180
Join Date: Nov 2012
Location: The Beaten Path, USA, Roundworld, This Side of Infinity
Device: Kindle Touch fw5.3.7 (Wifi only)
Excellent point... so you could import using

Code:
(?P<comments>.*)
And then select all books, select Edit Metadata, go to the Search and replace tab, and select
Search mode: Regular Expression
Search field: comments
Search for:
Code:
\[Novel\] ([^)(]+)\((.+)\) (\d+) (.*)
Then toggle through the following Replace with and Destination field sets:

for:
title: \1 -- #alt_title: \2 -- series: \1 -- series_index: \3 #status: \4


Replace with: \1
Destination field: title
---------------------------
Replace with: \2
Destination field: #alt_title
---------------------------
Replace with: \1
Destination field: series
---------------------------
Replace with: \3
Destination field: series_index
---------------------------
Replace with: \4
Destination field: #status


Wheeeee! But ugly as heck and takes quite a few steps. Definitely faster than hand-editing.

@xd1986k, you got that?
eschwartz is offline   Reply With Quote
Old 02-02-2015, 10:06 PM   #5
gbm
Wizard
gbm ought to be getting tired of karma fortunes by now.gbm ought to be getting tired of karma fortunes by now.gbm ought to be getting tired of karma fortunes by now.gbm ought to be getting tired of karma fortunes by now.gbm ought to be getting tired of karma fortunes by now.gbm ought to be getting tired of karma fortunes by now.gbm ought to be getting tired of karma fortunes by now.gbm ought to be getting tired of karma fortunes by now.gbm ought to be getting tired of karma fortunes by now.gbm ought to be getting tired of karma fortunes by now.gbm ought to be getting tired of karma fortunes by now.
 
Posts: 2,082
Karma: 8796704
Join Date: Jun 2010
Device: Kobo Clara HD,Hisence Sero 7 Pro RIP, Nook STR, jetbook lite
Calibre-Preferences- adding books-configure metadata from file name

Code:
(?P<author>[^_-]+) -?\s*(?P<series>[^_0-9-]*)(?P<series_index>[0-9]*)\s*-\s*(?P<title>[^_].+) ?
Code:
^((?P<author>([^\-_0-9]+)(?=\s*-\s*)(?!\s*-\s*[0-9.]+)|\b))(\s*-\s*)?(\[?(?P<series>[^0-9\-]+) (- )?(?P<series_index>[0-9.]+)\]?\s*-\s*)?(?P<title>[a-zA-Z1-9 ]+).+
Quote:
example filename: Charles Sheffield - [Cold as Ice 03] - Dark as Day
luck
bernie
gbm is offline   Reply With Quote
Advert
Old 02-02-2015, 10:13 PM   #6
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,422
Karma: 85397180
Join Date: Nov 2012
Location: The Beaten Path, USA, Roundworld, This Side of Infinity
Device: Kindle Touch fw5.3.7 (Wifi only)
Quote:
Originally Posted by gbm View Post
Calibre-Preferences- adding books-configure metadata from file name

Code:
(?P<author>[^_-]+) -?\s*(?P<series>[^_0-9-]*)(?P<series_index>[0-9]*)\s*-\s*(?P<title>[^_].+) ?
Code:
^((?P<author>([^\-_0-9]+)(?=\s*-\s*)(?!\s*-\s*[0-9.]+)|\b))(\s*-\s*)?(\[?(?P<series>[^0-9\-]+) (- )?(?P<series_index>[0-9.]+)\]?\s*-\s*)?(?P<title>[a-zA-Z1-9 ]+).+


luck
bernie
That would work even better if it related to the OP's needs.
eschwartz is offline   Reply With Quote
Old 02-02-2015, 10:26 PM   #7
gbm
Wizard
gbm ought to be getting tired of karma fortunes by now.gbm ought to be getting tired of karma fortunes by now.gbm ought to be getting tired of karma fortunes by now.gbm ought to be getting tired of karma fortunes by now.gbm ought to be getting tired of karma fortunes by now.gbm ought to be getting tired of karma fortunes by now.gbm ought to be getting tired of karma fortunes by now.gbm ought to be getting tired of karma fortunes by now.gbm ought to be getting tired of karma fortunes by now.gbm ought to be getting tired of karma fortunes by now.gbm ought to be getting tired of karma fortunes by now.
 
Posts: 2,082
Karma: 8796704
Join Date: Jun 2010
Device: Kobo Clara HD,Hisence Sero 7 Pro RIP, Nook STR, jetbook lite
Quote:
Originally Posted by eschwartz View Post
That would work even better if it related to the OP's needs.
He is importing ebooks, he can play with the regex to get it to his needs.

That will fill the metadata fields from the file name.
Quote:
Hello.
I have a bunch of files on my desktop that I'd like to import without a ton of manual metadata editing. I noticed the Regular Expression import from filename. I'm gonna get around to regex one of these days but in the meantime I'd be grateful if someone helped me.
bernie
gbm is offline   Reply With Quote
Old 02-02-2015, 10:33 PM   #8
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,422
Karma: 85397180
Join Date: Nov 2012
Location: The Beaten Path, USA, Roundworld, This Side of Infinity
Device: Kindle Touch fw5.3.7 (Wifi only)
Alternatively, say:

Quote:
Here is a handy link to a regex guide.
Importing metadata from filenames uses named capturing groups (to match the metadata field names).
Which would be helpful information, insomuch as it relates to how to do it, rather than canned solutions for an entirely different need (in a thread asking for canned solutions, without pointing out that those are sample concepts).
eschwartz is offline   Reply With Quote
Old 02-03-2015, 05:37 AM   #9
xd1986k
Member
xd1986k began at the beginning.
 
xd1986k's Avatar
 
Posts: 10
Karma: 10
Join Date: Dec 2014
Device: Kindle Fire HDX 7, Ipad
Quote:
Originally Posted by eschwartz View Post
Excellent point... so you could import using

Code:
(?P<comments>.*)
And then select all books, select Edit Metadata, go to the Search and replace tab, and select
Search mode: Regular Expression
Search field: comments
Search for:
Code:
\[Novel\] ([^)(]+)\((.+)\) (\d+) (.*)
Then toggle through the following Replace with and Destination field sets:

for:
title: \1 -- #alt_title: \2 -- series: \1 -- series_index: \3 #status: \4


Replace with: \1
Destination field: title
---------------------------
Replace with: \2
Destination field: #alt_title
---------------------------
Replace with: \1
Destination field: series
---------------------------
Replace with: \3
Destination field: series_index
---------------------------
Replace with: \4
Destination field: #status


Wheeeee! But ugly as heck and takes quite a few steps. Definitely faster than hand-editing.

@xd1986k, you got that?
Thanks a lot. Got my whole library set up in four steps .
xd1986k is offline   Reply With Quote
Old 02-03-2015, 10:42 AM   #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,422
Karma: 85397180
Join Date: Nov 2012
Location: The Beaten Path, USA, Roundworld, This Side of Infinity
Device: Kindle Touch fw5.3.7 (Wifi only)
Quote:
Originally Posted by xd1986k View Post
Thanks a lot. Got my whole library set up in four steps .
eschwartz is offline   Reply With Quote
Reply

Tags
importing books, regular expressions


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Regex: File Renaming Pre-Import & Importing penguinaka Library Management 20 08-14-2012 06:11 PM
Need a regex for importing books flinkdeldinky Calibre 31 10-29-2011 08:31 AM
Regex assistance request - importing books. Belfaborac Library Management 2 10-24-2011 08:03 AM
Importing RegEx Line TheEldest Calibre 1 07-05-2011 10:18 PM
regex Issue when Importing river Calibre 3 06-16-2009 11:03 AM


All times are GMT -4. The time now is 05:36 PM.


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