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-28-2020, 10:05 AM   #1
TreeFrogBandit
Junior Member
TreeFrogBandit began at the beginning.
 
Posts: 3
Karma: 10
Join Date: Feb 2020
Device: none
Question Custom column to show a truncated file path

I'm experimenting with custom columns, and I'd like to add one with the file path in it. The problem is that the formats_paths function gives me a list which is far too long.

First I get the formats information (which I don't need) and then I get the full path of each version of the file - when actually what I'm looking for is the element of the path that is unique to each book (i.e. the file path for a the folder the files are in, without the preceding information about where the library is)

For example, at the moment I would get something like:

"EPUB: C:\calibre library location which is a very long string\then the specific library that calibre is looking at\and finally the interesting bit\title.epub,ORIGINAL_EPUB: C:\calibre library location which is a very long string\then the specific library that calibre is looking at\and finally the interesting bit\title.original_epub" etc. etc

What I'd like to do is get something like:

"...\and finally the interesting bit\"

Sorry if this is difficult to follow, can anybody help me? I'm sure I'm not the only one who's wanted to do this...

Thanks!
TreeFrogBandit is offline   Reply With Quote
Old 02-28-2020, 03:56 PM   #2
BetterRed
null operator (he/him)
BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.
 
Posts: 20,567
Karma: 26954694
Join Date: Mar 2012
Location: Sydney Australia
Device: none
Quote:
Originally Posted by TreeFrogBandit View Post
I'm experimenting with custom columns, and I'd like to add one with the file path in it. The problem is that the formats_paths function gives me a list which is far too long.

First I get the formats information (which I don't need) and then I get the full path of each version of the file - when actually what I'm looking for is the element of the path that is unique to each book (i.e. the file path for a the folder the files are in, without the preceding information about where the library is)

For example, at the moment I would get something like:

"EPUB: C:\calibre library location which is a very long string\then the specific library that calibre is looking at\and finally the interesting bit\title.epub,ORIGINAL_EPUB: C:\calibre library location which is a very long string\then the specific library that calibre is looking at\and finally the interesting bit\title.original_epub" etc. etc

What I'd like to do is get something like:

"...\and finally the interesting bit\"

Sorry if this is difficult to follow, can anybody help me? I'm sure I'm not the only one who's wanted to do this...
Use a regular expression via the re function to parse the string you get from format_paths.

The "...\and finally the interesting bit\" would seem to be the directory name that is derived (ascii-ized and sanitized) from the first author name. I'm curious, no puzzled, why anyone would want such a thing - if they're interested they can just press O' and look at the top of the File Explorer window.

BR

Last edited by BetterRed; 02-28-2020 at 10:49 PM.
BetterRed is offline   Reply With Quote
Old 02-28-2020, 07:11 PM   #3
davidfor
Grand Sorcerer
davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.
 
Posts: 24,907
Karma: 47303748
Join Date: Jul 2011
Location: Sydney, Australia
Device: Kobo:Touch,Glo, AuraH2O, GloHD,AuraONE, ClaraHD, Libra H2O; tolinoepos
Firstly, the formats_paths function returns exactly what it is supposed to. It returns a list of the full paths for each format for the book with the format as a prefix. When using the Template editor, you can see the definition of each function by selecting the function lower half of the editor.

As to your template, I think you are after the name of the directory that holds the book. The following will do this:

Code:
{:'re(formats_paths(),".*\\([^\\]*?)\\[^\\]*?$","\1")'}
The only problem with this is if there are no formats for the book.

If you need to do this on a non-Windows box, the path separator will need to be changed.
davidfor is offline   Reply With Quote
Reply

Tags
column settings, cutstomizing, path


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Column to show file date Bigo2 Library Management 2 12-28-2016 03:12 AM
Plugin or custom column to show GB size of book mom34spartan Plugins 5 07-08-2013 09:07 AM
custom column: count number of characters (in book path) miquele Library Management 25 09-21-2012 01:54 PM
Custom column showing path length? xterminal Library Management 1 09-11-2012 09:12 AM
Kindle: Show ebook reading status in custom column AndyW1691 Library Management 0 01-22-2012 04:40 PM


All times are GMT -4. The time now is 10:50 PM.


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