|
|||||||
![]() |
|
|
Thread Tools | Search this Thread |
|
|
#1 |
|
Junior Member
![]() Posts: 6
Karma: 10
Join Date: Jul 2026
Device: none
|
Regex search & replace giving inconsistent results when pulling from "Path" field
I'm trying to pull the exact name of all files via the "Path" field, since Calibre handles special characters in the title differently on export, and there doesn't seem to be an option to directly export a list of the Path in the export catalogue option.
Whenever I do this, the title case of the words isn't always consistent for certain files, and since epub files are case-sensitive, it doesn't identify the file when the name doesn't match exactly. I've tried pulling using the following templates in regex search and replace: Code:
program: p = $path; re(p, '^.*/(.+)\s\([0-9]+\)','\1') Code:
program: p = $path; p = re(p,".+\/",""); p = re(p,"\s\([0-9]+\)$",""); Code:
python:
import re
def evaluate(book, context):
p = book.get('path')
p = re.search('(?<=./).+(?=\s\([0-9]+\))',p)
return p.group(0)
It doesn't only occur with cases where I have duplicate titles, but it's easiest to demonstrate with that. In the screenshot, the first time I run any of the searches above, it will show the correct "Amortentia", which is capitalized. Then if I preview it for the second line, it will show the correct "amortentia" in lower case for the second file, and after I run the search and replace, it will change both of them to "amortentia". And then if I go back to try and change the first one, it will again change both to "Amortentia". I am running this on my entire library, so the results continue to fluctuate until the library is done. Is there something that's wrong with my regex searches, or the way the Path column is handled? In the image, the first Path column is the default calibre column, and the second Path column is custom column where I've run the search and replace. |
|
|
|
|
|
#2 |
|
creator of calibre
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 46,475
Karma: 29634066
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
Not sure what you are trying to do. I dont know what case sensitivity of epub files has to do with file **names**? And you can absolutely export paths using the catalog feature.
|
|
|
|
| Advert | |
|
|
|
|
#3 | |
|
Junior Member
![]() Posts: 6
Karma: 10
Join Date: Jul 2026
Device: none
|
I'm essentially trying to compare a list of files currently in my calibre library against the actual files in my computer because something went weird with my file manager ... still figuring that part out.
But I can't just export the title, because Calibre changes certain special characters in the title name to _ instead. Quote:
I've attached screenshots, unless it's somewhere else I'm supposed to be looking? |
|
|
|
|
|
|
#4 |
|
creator of calibre
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 46,475
Karma: 29634066
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
Use the dedicated library maintenance tool for that. Right click the library icon in the main calibre toolbar and choose Library maintenance
|
|
|
|
![]() |
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| search & replace doesnt work with "newlines" in PDF to MOBI conversion | fred410 | Conversion | 0 | 02-28-2021 05:13 PM |
| 5.1.0 bug in "search and replace" regex field | Snowman | Library Management | 4 | 10-05-2020 10:17 AM |
| Destination "uuid" in Search & Replace Metdata dialog | halloleo | Library Management | 8 | 03-08-2020 10:50 PM |
| Default "find" for Search/Replace regex functions | vr8ce | Editor | 14 | 02-02-2018 10:41 AM |
| Missing "function mode" for editor's Search & Replace | atux | Editor | 3 | 01-17-2016 08:40 AM |