Register Guidelines E-Books Today's Posts Search

Go Back   MobileRead Forums > E-Book Software > Calibre

Notices

Reply
 
Thread Tools Search this Thread
Old 07-10-2025, 02:00 AM   #16
edojan
Connoisseur
edojan can tame squirrels without the assistance of a chair or a whip.edojan can tame squirrels without the assistance of a chair or a whip.edojan can tame squirrels without the assistance of a chair or a whip.edojan can tame squirrels without the assistance of a chair or a whip.edojan can tame squirrels without the assistance of a chair or a whip.edojan can tame squirrels without the assistance of a chair or a whip.edojan can tame squirrels without the assistance of a chair or a whip.edojan can tame squirrels without the assistance of a chair or a whip.edojan can tame squirrels without the assistance of a chair or a whip.edojan can tame squirrels without the assistance of a chair or a whip.edojan can tame squirrels without the assistance of a chair or a whip.
 
Posts: 68
Karma: 11226
Join Date: Mar 2022
Device: Kobo Libra 2, Aura H2O
Random number of characters in truncated file names

Quote:
Originally Posted by kovidgoyal View Post
When sending to devices calibre always truncates to 256 as various devices have various limitations.
Sorry to bring this up again. I wonder if you can help to resolve The issue under windows 11 is as follows: if a book has a relatively long title in metadata (e.g. 70-75 characters) when it is added to Calibre library, the file name automatically generated by Calibre would be truncated to a random number of characters. Some file names would become 51 characters long, others - 55 characters, etc. When copied to devices (in my case Kobo Sage), the file names are not truncated at all (since they are less than 250 characters). Hence the files between the windows library and the device are named differently and have different hush numbers. This causes all kinds of problems when I am trying to synchronize of metadata generated by Koreader, etc. Since the same books are treated as different ones.
How can I have exactly the same file names between the main library in windows and file names copied to non-windows devices? E.g. if due to whatever limitation the book file in Calibre is 51 character long, then it would be transferred to connected devices without any changes. I would really appreciate your insight on how to resolve this.
edojan is offline   Reply With Quote
Old 07-10-2025, 03:12 AM   #17
DNSB
Bibliophagist
DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.
 
DNSB's Avatar
 
Posts: 46,190
Karma: 168983734
Join Date: Jul 2010
Location: Vancouver
Device: Kobo Sage, Libra Colour, Lenovo M8 FHD, Paperwhite 4, Tolino epos
The file name sent to your ereader should be set from metadata depending on the template you use when saving. The name in the calibre library is not really relevant. Basically use the calibre library directory as a black box and stop peeking under it's skirts.

You may want to look at the location for your calibre library and move it to a location that has a shorter path. i.e. D:\Calibre\<library name>.

OTOH, out of perhaps morbid curiosity, what is a hush number? You may want to disable updating metadata in the file when it is being sent from calibre to your Sage since that can and will modify the file hash.

Depending on what file system you are using, other limitations may be present.

If you are trying to use very long file paths, have you set FileSystem LongPathsEnabled to enabled in the registry and does the application have set longPathAware true in the application's manifest?
DNSB is offline   Reply With Quote
Old 07-10-2025, 06:32 AM   #18
Quoth
Still reading
Quoth ought to be getting tired of karma fortunes by now.Quoth ought to be getting tired of karma fortunes by now.Quoth ought to be getting tired of karma fortunes by now.Quoth ought to be getting tired of karma fortunes by now.Quoth ought to be getting tired of karma fortunes by now.Quoth ought to be getting tired of karma fortunes by now.Quoth ought to be getting tired of karma fortunes by now.Quoth ought to be getting tired of karma fortunes by now.Quoth ought to be getting tired of karma fortunes by now.Quoth ought to be getting tired of karma fortunes by now.Quoth ought to be getting tired of karma fortunes by now.
 
Quoth's Avatar
 
Posts: 14,025
Karma: 105092227
Join Date: Jun 2017
Location: Ireland
Device: All 4 Kinds: epub eink, Kindle, android eink, NxtPaper
And with long paths Backups will fail. Actually backups and copies can fail even with regular paths if the names of directories or files are too long.
Quoth is offline   Reply With Quote
Old 07-10-2025, 01:22 PM   #19
edojan
Connoisseur
edojan can tame squirrels without the assistance of a chair or a whip.edojan can tame squirrels without the assistance of a chair or a whip.edojan can tame squirrels without the assistance of a chair or a whip.edojan can tame squirrels without the assistance of a chair or a whip.edojan can tame squirrels without the assistance of a chair or a whip.edojan can tame squirrels without the assistance of a chair or a whip.edojan can tame squirrels without the assistance of a chair or a whip.edojan can tame squirrels without the assistance of a chair or a whip.edojan can tame squirrels without the assistance of a chair or a whip.edojan can tame squirrels without the assistance of a chair or a whip.edojan can tame squirrels without the assistance of a chair or a whip.
 
Posts: 68
Karma: 11226
Join Date: Mar 2022
Device: Kobo Libra 2, Aura H2O
Thanks for your response. Please see below.

Quote:
Originally Posted by DNSB View Post
The file name sent to your ereader should be set from metadata depending on the template you use when saving. The name in the calibre library is not really relevant. Basically use the calibre library directory as a black box and stop peeking under it's skirts.
This is my understanding as well. The issue is that the same metadata produces different file names in Calibre library and the device irrespective of the template used.

Quote:
You may want to look at the location for your calibre library and move it to a location that has a shorter path. i.e. D:\Calibre\<library name>.
Unfortunately, not feasible. The library is being synced to OneDrive and as such is located in C:/users/username/etc.

Quote:
OTOH, out of perhaps morbid curiosity, what is a hush number?

Quote:
You may want to disable updating metadata in the file when it is being sent from calibre to your Sage since that can and will modify the file hash. Depending on what file system you are using, other limitations may be present.
This was done earlier. Unfortunately, due to the file name differences the hashes are different even if when there is no change in the metadata

Quote:
If you are trying to use very long file paths, have you set FileSystem LongPathsEnabled to enabled in the registry and does the application have set longPathAware true in the application's manifest?
FileSystem LongPathsEnabled was/is set to 1 (true), but I don't know how to change the application's manifest.
I wish there was a setting "keep device file names the same as in Calibre library" This would be ideal
edojan is offline   Reply With Quote
Old 07-10-2025, 01:57 PM   #20
JSWolf
Resident Curmudgeon
JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.
 
JSWolf's Avatar
 
Posts: 79,750
Karma: 145864619
Join Date: Nov 2006
Location: Roslindale, Massachusetts
Device: Kobo Libra 2, Kobo Aura H2O, PRS-650, PRS-T1, nook STR, PW3
Quote:
Originally Posted by edojan View Post
Thanks for your response. Please see below.



This is my understanding as well. The issue is that the same metadata produces different file names in Calibre library and the device irrespective of the template used.


Unfortunately, not feasible. The library is being synced to OneDrive and as such is located in C:/users/username/etc.




This was done earlier. Unfortunately, due to the file name differences the hashes are different even if when there is no change in the metadata


FileSystem LongPathsEnabled was/is set to 1 (true), but I don't know how to change the application's manifest.
I wish there was a setting "keep device file names the same as in Calibre library" This would be ideal
Turn off OneDrive. They way you have it set can cause all kinds of problems. And you NEVER EVER want tot two-way sync your library. Move your library so OneDrive will not touch it.
JSWolf is offline   Reply With Quote
Old 07-10-2025, 02:09 PM   #21
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: 12,447
Karma: 8012886
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Quote:
Originally Posted by edojan View Post
This is my understanding as well. The issue is that the same metadata produces different file names in Calibre library and the device irrespective of the template used.
You have no control over calibre file names. There is no template you can set to control how calibre generates file names. Calibre can change a filename any time metadata changes.

On the other hand, you can use the format_paths() template function to get the current library file path for a book's formats and use that when sending to your device. Of course this won't help with long path names.
chaley is offline   Reply With Quote
Old 07-10-2025, 02:59 PM   #22
edojan
Connoisseur
edojan can tame squirrels without the assistance of a chair or a whip.edojan can tame squirrels without the assistance of a chair or a whip.edojan can tame squirrels without the assistance of a chair or a whip.edojan can tame squirrels without the assistance of a chair or a whip.edojan can tame squirrels without the assistance of a chair or a whip.edojan can tame squirrels without the assistance of a chair or a whip.edojan can tame squirrels without the assistance of a chair or a whip.edojan can tame squirrels without the assistance of a chair or a whip.edojan can tame squirrels without the assistance of a chair or a whip.edojan can tame squirrels without the assistance of a chair or a whip.edojan can tame squirrels without the assistance of a chair or a whip.
 
Posts: 68
Karma: 11226
Join Date: Mar 2022
Device: Kobo Libra 2, Aura H2O
Quote:
Originally Posted by chaley View Post
You have no control over calibre file names. There is no template you can set to control how calibre generates file names. Calibre can change a filename any time metadata changes.
Understood. Changes in metadata are disabled. This is not an issue.
Quote:
On the other hand, you can use the format_paths() template function to get the current library file path for a book's formats and use that when sending to your device. Of course this won't help with long path names.
I moved the library to a very short path:
Code:
C:\VAULTS\
This made no difference as Calibre keeps truncating the file names. E.g. the following book's name (as it appears in the metadata file) is
Code:
<dc:title>Исцеление духовных болезней</dc:title>
. Calibre adds this book to the library as
Code:
C:\VAULTS\CalibVault\Zhan-Klod Larshie\Istsielieniie dukhovnykh boliezniei (517)\Istsielieniie dukhovnykh boliez - Zhan-Klod Larshie.epub
The same book is transferred to the sage as:
Code:
E:\Zhan-Klod Larshie\Istsielieniie dukhovnykh boliezniei - Zhan-Klod Larshie.epub
The epub's file name is not the same. Calibre truncates it to
Code:
"Istsielieniie dukhovnykh boliez - Zhan-Klod Larshie.epub"
and on the device it appears as:
Code:
"Istsielieniie dukhovnykh boliezniei - Zhan-Klod Larshie.epub"
The difference is 4 characters. This screws up the file hash.

Last edited by edojan; 07-10-2025 at 03:01 PM.
edojan is offline   Reply With Quote
Old 07-10-2025, 03:04 PM   #23
edojan
Connoisseur
edojan can tame squirrels without the assistance of a chair or a whip.edojan can tame squirrels without the assistance of a chair or a whip.edojan can tame squirrels without the assistance of a chair or a whip.edojan can tame squirrels without the assistance of a chair or a whip.edojan can tame squirrels without the assistance of a chair or a whip.edojan can tame squirrels without the assistance of a chair or a whip.edojan can tame squirrels without the assistance of a chair or a whip.edojan can tame squirrels without the assistance of a chair or a whip.edojan can tame squirrels without the assistance of a chair or a whip.edojan can tame squirrels without the assistance of a chair or a whip.edojan can tame squirrels without the assistance of a chair or a whip.
 
Posts: 68
Karma: 11226
Join Date: Mar 2022
Device: Kobo Libra 2, Aura H2O
Quote:
Originally Posted by JSWolf View Post
Turn off OneDrive. They way you have it set can cause all kinds of problems. And you NEVER EVER want tot two-way sync your library. Move your library so OneDrive will not touch it.
I only kept it on OneDrive for backup purposes and always added books directly via Calibre (that is never directly via OneDrive). But just in case I just moved the libraries to a directory on C:\
edojan is offline   Reply With Quote
Old 07-10-2025, 03:30 PM   #24
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: 12,447
Karma: 8012886
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
As I said, calibre chooses how to name files using whatever algorithm is in the release when the file is created. The algorithm is complex, taking into consideration lengths of the title, authors, path to library, and library ID. You cannot turn off calibre's actions when metadata changes. Others have tried to reproduce calibre's naming with templates. To my knowledge, during 15 years none have been successful.

Your only chance is to use the calibre-generated name, available via format_paths(). Or
chaley is offline   Reply With Quote
Old 07-10-2025, 03:59 PM   #25
edojan
Connoisseur
edojan can tame squirrels without the assistance of a chair or a whip.edojan can tame squirrels without the assistance of a chair or a whip.edojan can tame squirrels without the assistance of a chair or a whip.edojan can tame squirrels without the assistance of a chair or a whip.edojan can tame squirrels without the assistance of a chair or a whip.edojan can tame squirrels without the assistance of a chair or a whip.edojan can tame squirrels without the assistance of a chair or a whip.edojan can tame squirrels without the assistance of a chair or a whip.edojan can tame squirrels without the assistance of a chair or a whip.edojan can tame squirrels without the assistance of a chair or a whip.edojan can tame squirrels without the assistance of a chair or a whip.
 
Posts: 68
Karma: 11226
Join Date: Mar 2022
Device: Kobo Libra 2, Aura H2O
Quote:
Originally Posted by chaley View Post
Your only chance is to use the calibre-generated name, available via format_paths(). Or
Is there a way to use format_paths() to transfer the calibre-generated name to the devices? How? My current template to send to the device is {author}/{title} - {authors}
edojan is offline   Reply With Quote
Old 07-10-2025, 04:27 PM   #26
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: 12,447
Karma: 8012886
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Quote:
Originally Posted by edojan View Post
Is there a way to use format_paths() to transfer the calibre-generated name to the devices? How? My current template to send to the device is {author}/{title} - {authors}
Use the template language documented in the calibre manual. https://manual.calibre-ebook.com/template_lang.html. in particular, General Program Mode.
chaley is offline   Reply With Quote
Old 07-10-2025, 05:53 PM   #27
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: 12,447
Karma: 8012886
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
The formats_path() function has problems if authors contain a comma. I need to fix this in base calibre.

In the meantime, this python template returns the basename of the book file
Code:
python:
def evaluate(book, context):
	import os
	from calibre.library import current_library_path

	fmt_metadata = book.get('format_metadata')
	if fmt_metadata:
		for v in fmt_metadata.values():
			# A calibre format name is roughly "author/title (id)/title - author.extension"
			# We want to return the last segment, stripping off the author and title 
			# directory names and the extension, leaving just the basename of the book file
			f = v['path']
			return f[f.rfind(os.sep)+1:f.rfind('.')] 
	else:
		raise ValueError('Book "{}" has no formats'.format(book.title))
chaley is offline   Reply With Quote
Old 07-10-2025, 06:22 PM   #28
edojan
Connoisseur
edojan can tame squirrels without the assistance of a chair or a whip.edojan can tame squirrels without the assistance of a chair or a whip.edojan can tame squirrels without the assistance of a chair or a whip.edojan can tame squirrels without the assistance of a chair or a whip.edojan can tame squirrels without the assistance of a chair or a whip.edojan can tame squirrels without the assistance of a chair or a whip.edojan can tame squirrels without the assistance of a chair or a whip.edojan can tame squirrels without the assistance of a chair or a whip.edojan can tame squirrels without the assistance of a chair or a whip.edojan can tame squirrels without the assistance of a chair or a whip.edojan can tame squirrels without the assistance of a chair or a whip.
 
Posts: 68
Karma: 11226
Join Date: Mar 2022
Device: Kobo Libra 2, Aura H2O
Quote:
Originally Posted by chaley View Post
The formats_path() function has problems if authors contain a comma. I need to fix this in base calibre.

In the meantime, this python template returns the basename of the book file
Code:
python:
def evaluate(book, context):
	import os
	from calibre.library import current_library_path

	fmt_metadata = book.get('format_metadata')
	if fmt_metadata:
		for v in fmt_metadata.values():
			# A calibre format name is roughly "author/title (id)/title - author.extension"
			# We want to return the last segment, stripping off the author and title 
			# directory names and the extension, leaving just the basename of the book file
			f = v['path']
			return f[f.rfind(os.sep)+1:f.rfind('.')] 
	else:
		raise ValueError('Book "{}" has no formats'.format(book.title))
Thanks chaley for your assistance,
I really appreciate it. The problem is that I am not very technical. Would it be too much to ask for more detailed instructions? I have tried entering the code in the template editor, but it produces an error. What steps am I missing?
edojan is offline   Reply With Quote
Old 07-10-2025, 06:38 PM   #29
edojan
Connoisseur
edojan can tame squirrels without the assistance of a chair or a whip.edojan can tame squirrels without the assistance of a chair or a whip.edojan can tame squirrels without the assistance of a chair or a whip.edojan can tame squirrels without the assistance of a chair or a whip.edojan can tame squirrels without the assistance of a chair or a whip.edojan can tame squirrels without the assistance of a chair or a whip.edojan can tame squirrels without the assistance of a chair or a whip.edojan can tame squirrels without the assistance of a chair or a whip.edojan can tame squirrels without the assistance of a chair or a whip.edojan can tame squirrels without the assistance of a chair or a whip.edojan can tame squirrels without the assistance of a chair or a whip.
 
Posts: 68
Karma: 11226
Join Date: Mar 2022
Device: Kobo Libra 2, Aura H2O
here is the screenshot
Attached Thumbnails
Click image for larger version

Name:	template.png
Views:	26
Size:	61.1 KB
ID:	216832  
edojan is offline   Reply With Quote
Old 07-10-2025, 10:39 PM   #30
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: 12,447
Karma: 8012886
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
That error is harmless, caused by the template dialog not having a real book to work with. It will work when it us run "for real" -- when sending to the device.

This version removes the error.
Code:
python:
def evaluate(book, context):
	import os
	from calibre.library import current_library_path

	fmt_metadata = book.get('format_metadata')
	if fmt_metadata:
		for v in fmt_metadata.values():
			# A calibre format name is roughly "author/title (id)/title - author.extension"
			# We want to return the last segment, stripping off the author and title 
			# directory names and the extension, leaving just the basename of the book file
			f = v['path']
			return f[f.rfind(os.sep)+1:f.rfind('.')] 
	else:
		return 'title - author'
chaley is offline   Reply With Quote
Reply


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Problem with Calibre's folder structure and long names in Windows crixtiano Calibre 1 07-28-2017 02:05 PM
Calibre taking a long, long time to update metadata on sony prs650 hydin Calibre 5 06-05-2012 12:21 AM
Is there anything in Calibre that can fix long file names automatically? dmunson Calibre 4 02-05-2012 06:12 PM
File Names to long? JTAL604622 Calibre 5 08-31-2011 03:21 AM
Files with long names? cmhsieh54 iRex 0 08-05-2009 12:43 PM


All times are GMT -4. The time now is 08:06 PM.


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