View Single Post
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: 21,786
Karma: 30237628
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