Register Guidelines E-Books Search Today's Posts Mark Forums Read

Go Back   MobileRead Forums > E-Book Software > Calibre

Notices

Reply
 
Thread Tools Search this Thread
Old 03-16-2013, 04:24 AM   #1
Giuseppe Chillem
Groupie
Giuseppe Chillem doesn't litterGiuseppe Chillem doesn't litter
 
Giuseppe Chillem's Avatar
 
Posts: 178
Karma: 134
Join Date: May 2010
Device: IREX DR1000
How to copy only first N character from filename ?

Hi,
is there a RegEx way to copy only the first N characters from Title to the ISBN field ?

Thanks in advance
Giuseppe Chillem is offline   Reply With Quote
Old 03-16-2013, 05:02 AM   #2
chaley
Grand Sorcerer
chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.
 
Posts: 11,728
Karma: 6690881
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Using bulk edit search & replace:

Search field: title
Search for: ^(.{5}).*
Replace with: \1
Destination field: identifiers
Identifier type: isbn

Replace the "5" in Search for with the number you really want.
chaley is offline   Reply With Quote
Old 03-16-2013, 12:34 PM   #3
Giuseppe Chillem
Groupie
Giuseppe Chillem doesn't litterGiuseppe Chillem doesn't litter
 
Giuseppe Chillem's Avatar
 
Posts: 178
Karma: 134
Join Date: May 2010
Device: IREX DR1000
Quote:
Originally Posted by chaley View Post
Using bulk edit search & replace:

Search field: title
Search for: ^(.{5}).*
Replace with: \1
Destination field: identifiers
Identifier type: isbn

Replace the "5" in Search for with the number you really want.
Chaley, Those Regular Expression do not want to enter into my mind. I suppose I will ask about them forever...

Thanks !

Last edited by Giuseppe Chillem; 03-16-2013 at 12:36 PM.
Giuseppe Chillem is offline   Reply With Quote
Old 03-16-2013, 12:55 PM   #4
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,762
Karma: 54401244
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 Giuseppe Chillem View Post
Chaley, Those Regular Expression does not want to enter my mind. I suppose I will ask about them forever...

Thanks !
It took me a LONG time to get it.

Decoding:
Code:
^ must be at the beginning of the line
( start the [first] capture sequence
the dot any character
{x}   Repetition rule   5 exactly 5 times,  2,5 would be 2 to 5 times,
) end of [first] capture 

the replace:
\1 use the [first capture value]
IMHO dot is not a great match choice (for ISBN) as it assumes that the input is always a valid ISBN< to write a rule you need to know your data rules, and EXCEPTIONS >

ISBN 10 can have an 'X' as the last ^(\d{9}(\d|X|x)) not tested
this supposed to say Match the first 9 digits from the start AND match the next if it is a digit OR x (either case)
theducks is offline   Reply With Quote
Old 03-17-2013, 04:50 PM   #5
Giuseppe Chillem
Groupie
Giuseppe Chillem doesn't litterGiuseppe Chillem doesn't litter
 
Giuseppe Chillem's Avatar
 
Posts: 178
Karma: 134
Join Date: May 2010
Device: IREX DR1000
Quote:
Originally Posted by theducks View Post
It took me a LONG time to get it.

Decoding:
Code:
^ must be at the beginning of the line
( start the [first] capture sequence
the dot any character
{x}   Repetition rule   5 exactly 5 times,  2,5 would be 2 to 5 times,
) end of [first] capture 

the replace:
\1 use the [first capture value]
IMHO dot is not a great match choice (for ISBN) as it assumes that the input is always a valid ISBN< to write a rule you need to know your data rules, and EXCEPTIONS >

ISBN 10 can have an 'X' as the last ^(\d{9}(\d|X|x)) not tested
this supposed to say Match the first 9 digits from the start AND match the next if it is a digit OR x (either case)
Tested, it takes the remaining part of the string:

1616084855IWIWEF -> IWIWEF
Giuseppe Chillem is offline   Reply With Quote
Old 03-17-2013, 05:01 PM   #6
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,762
Karma: 54401244
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 Giuseppe Chillem View Post
Tested, it takes the remaining part of the string:

1616084855IWIWEF -> IWIWEF
Did you forget the ^ at the beginning?

BTW I just did a test in Sigil:
Find found the ISBN

Then I changed the lat 5 to an x
It found that kind also. Slash 1 contained the ISBN Captured
theducks is offline   Reply With Quote
Old 03-17-2013, 11:25 PM   #7
Adoby
Handy Elephant
Adoby ought to be getting tired of karma fortunes by now.Adoby ought to be getting tired of karma fortunes by now.Adoby ought to be getting tired of karma fortunes by now.Adoby ought to be getting tired of karma fortunes by now.Adoby ought to be getting tired of karma fortunes by now.Adoby ought to be getting tired of karma fortunes by now.Adoby ought to be getting tired of karma fortunes by now.Adoby ought to be getting tired of karma fortunes by now.Adoby ought to be getting tired of karma fortunes by now.Adoby ought to be getting tired of karma fortunes by now.Adoby ought to be getting tired of karma fortunes by now.
 
Adoby's Avatar
 
Posts: 1,736
Karma: 26785668
Join Date: Dec 2009
Location: Southern Sweden, far out in the quiet woods
Device: Thinkpad E595, Ubuntu Mate, Huawei Mediapad 5, Bouye Likebook Plus
I suspect that the /1 was not used in the replace dialog.

In the Replace With box /1 must be specified, otherwise you have specified that you want to replace the matched isbn with nothing, in effect deleting it. And you end up with:

1616084855IWIWEF -> IWIWEF

The /1 specifies that you want to use the contents of the first matching parentheses. The matched isbn.

Last edited by Adoby; 03-17-2013 at 11:28 PM.
Adoby is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
"Copy to Libary (delete after copy)" - Placement Suggestion plib Library Management 8 07-17-2012 09:53 PM
using filename for title pj123 Calibre 1 05-22-2011 06:18 PM
soft copy vs. hard copy no more. smokey News 4 12-02-2007 02:57 PM
txt filename? fishcube Sony Reader 1 10-19-2007 12:56 AM
gmail copy (gmcp) - Perl script to copy files to/from Gmail Colin Dunstan Lounge 0 09-04-2004 01:24 PM


All times are GMT -4. The time now is 02:34 PM.


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