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 10-12-2011, 07:26 AM   #1
iomari
Zealot
iomari doesn't litteriomari doesn't litter
 
iomari's Avatar
 
Posts: 134
Karma: 100
Join Date: Aug 2003
Location: Nigeria
Device: galaxy tab
calibredb list

when I run the cli command:

calibredb list --help

Part of the output is:

-f FIELDS, --fields=FIELDS
The fields to display when listing books in the
database. Should be a comma separated list of fields.
Available fields: *date_entered,*formats,*myformats,*s
ep_tots,*supercat,*timestamp,*totsize,author_sort, auth
ors,comments,cover,formats,identifiers,isbn,last_m odif
ied,pubdate,publisher,rating,series,series_index,s ize,
tags,timestamp,title,uuid
Default: title,authors. The special field "all" can be
used to select all fields. Only has effect in the text
output format.


However, when I run the command:

calibredb list --separator="," --fields=supercat

It returns with the help screen and the last line is:

Invalid fields. Available fields: *date_entered,*formats,*myformats,*sep_tots,*super cat,*timestamp,*totsize,author_sort,authors,commen ts,cover,formats,identifiers,isbn,last_modified,pu bdate,publisher,rating,series,series_index,size,ta gs,timestamp,title,uuid

However this clearly shows that "supercat" is a field.

Problem 2:

when I run:

calibredb list --separator="," --fields=formats

I get this list: (just a snippet)

1344,[/home/iomari/calibre_library/iomari/Tony Gaddis/Starting Out With Python (1344)/Starting Out With Python - Tony Gaddis.pdf] ,
1345,[/home/iomari/calibre_library/iomari/Steven Bird/Natural Language Processing With Python (1345)/Natural Language Processing With Python - Steven ,
,Bird.pdf]


This is not what I expected from "formats:.
I expected to see just the formats like "EPUB, PDF..."

The reason I'm going through this exercise is because I need to get a list of the formats used in my database. Like you get under "Formats" int the GUI. So this is my first step so I can import this output to my script. Unless someone knows a simpler way to get a list of all the formats used as a list.

Last edited by iomari; 10-12-2011 at 07:31 AM.
iomari is offline   Reply With Quote
Old 10-12-2011, 10:00 AM   #2
Starson17
Wizard
Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.
 
Posts: 4,004
Karma: 177841
Join Date: Dec 2009
Device: WinMo: IPAQ; Android: HTC HD2, Archos 7o; Java:Gravity T
Quote:
Originally Posted by iomari View Post
It returns with the help screen and the last line is:

Invalid fields. Available fields: *date_entered,*formats,*myformats,*sep_tots,*super cat,*timestamp,*totsize,author_sort,authors,commen ts,cover,formats,identifiers,isbn,last_modified,pu bdate,publisher,rating,series,series_index,size,ta gs,timestamp,title,uuid

However this clearly shows that "supercat" is a field.
No, it shows that "*supercat" is the custom field reference, not "supercat". It works for me on my custom fields (text format field).

Quote:
Problem 2:
This is not what I expected from "formats:.
I expected to see just the formats like "EPUB, PDF..."
That does seem odd I get the same thing. It's possible to run an SQL query through the command line tools. That could pull the format list.
Starson17 is offline   Reply With Quote
Old 10-12-2011, 10:24 AM   #3
DoctorOhh
US Navy, Retired
DoctorOhh ought to be getting tired of karma fortunes by now.DoctorOhh ought to be getting tired of karma fortunes by now.DoctorOhh ought to be getting tired of karma fortunes by now.DoctorOhh ought to be getting tired of karma fortunes by now.DoctorOhh ought to be getting tired of karma fortunes by now.DoctorOhh ought to be getting tired of karma fortunes by now.DoctorOhh ought to be getting tired of karma fortunes by now.DoctorOhh ought to be getting tired of karma fortunes by now.DoctorOhh ought to be getting tired of karma fortunes by now.DoctorOhh ought to be getting tired of karma fortunes by now.DoctorOhh ought to be getting tired of karma fortunes by now.
 
DoctorOhh's Avatar
 
Posts: 8,908
Karma: 12755553
Join Date: Feb 2009
Location: North Carolina
Device: Nexus 7
I'm ignorant and have never done this, but don't you have to use #supercat vice supercat?
DoctorOhh is offline   Reply With Quote
Old 10-12-2011, 10:47 AM   #4
iomari
Zealot
iomari doesn't litteriomari doesn't litter
 
iomari's Avatar
 
Posts: 134
Karma: 100
Join Date: Aug 2003
Location: Nigeria
Device: galaxy tab
Quote:
Originally Posted by dwanthny View Post
I'm ignorant and have never done this, but don't you have to use #supercat vice supercat?
I tried that first. doesn't work either.

-> calibredb list --separator="," --fields=#supercat
zsh: no matches found: --fields=#supercat


Starson17 can you give me the correct syntax? Also, thanks for the hint to use the database directly. i'll try that.

Last edited by iomari; 10-12-2011 at 10:50 AM.
iomari is offline   Reply With Quote
Old 10-12-2011, 11:12 AM   #5
iomari
Zealot
iomari doesn't litteriomari doesn't litter
 
iomari's Avatar
 
Posts: 134
Karma: 100
Join Date: Aug 2003
Location: Nigeria
Device: galaxy tab
The following gives me a list of all formats in my database without repeats:

sqlite3 path_to_/metadata.db "select * from data;" | cut -d "|" -f 3 | sort | uniq

Now I can feed that list into the script I'm writing to export my books to folders based on formats. I'll post it when I finish it.
Of course this is my solution for linux. :-)
iomari is offline   Reply With Quote
Old 10-12-2011, 11:32 AM   #6
Starson17
Wizard
Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.
 
Posts: 4,004
Karma: 177841
Join Date: Dec 2009
Device: WinMo: IPAQ; Android: HTC HD2, Archos 7o; Java:Gravity T
Quote:
Originally Posted by iomari View Post
I tried that first. doesn't work either.
@dwanthny: I thought that was the correct syntax, too. It didn't work, but this did:
Quote:
calibredb list --separator="," --fields=*supercat
Quote:
Starson17 can you give me the correct syntax?
See above.

Quote:
Also, thanks for the hint to use the database directly. i'll try that.
I'm glad it worked for you. Don't try to change anything in the database, but you can read things (it works in Windows, also, and you will find some early posts from me on duplicate finding on doing this).

It's also possible to execute Python code directly. When I wrote the Merge code and the Automerge code, I had to cycle through the formats in the formats field, so there are tools to do it with Calibre that can be used without directly accessing the database, if you need that.
Starson17 is offline   Reply With Quote
Old 10-12-2011, 11:57 AM   #7
iomari
Zealot
iomari doesn't litteriomari doesn't litter
 
iomari's Avatar
 
Posts: 134
Karma: 100
Join Date: Aug 2003
Location: Nigeria
Device: galaxy tab
Starson17 I just finished this quick and dirty script and it works. However I'll look at the routines you wrote and see it I can use them instead.

Ok, here is my first draft. It works exactly the way I want. Unfortunately I'm just starting with python so I wrote it in Perl first then i'll port it later tonight. If anyone can improve on this please do so: (of course you'll change the variables as needed"
Let me also say that running this takes a very long time as it scans through the database for each format. I presently have 1300 books.

#!/usr/bin/perl
my $dfolder = "/temp2/iomari/all" ;
my $lfolder = "/home/iomari/calibre_library/iomari/" ;
my $database = "metadata.db" ;
my @format = `sqlite3 $lfolder$database \"select \* from data\;\" | cut -d \"|\" -f 3 | sort | uniq` ;
my $dest = "/temp2/all/iomari" ;
my $buff ;

print "\ndeleting previous backed up books................." ;
`rm -rf $dest."/*"` ;
print "\n" ;
for $buff (@format)
{
chomp($buff) ;
print "exporting $buff files..............\n" ;
print "calibredb export --formats=$buff --template=\"$buff/{#supercat}/{tags}/{authors}/{title} - {authors}\" --to-dir=$dest --to-lowercase --all\n" ;
system "calibredb export --formats=$buff --template=\"$buff/{#supercat}/{tags}/{authors}/{title} - {authors}\" --to-dir=$dest --to-lowercase --all" ;
}
print "\nfinished\n" ;
exit ;

Last edited by iomari; 10-12-2011 at 12:02 PM.
iomari is offline   Reply With Quote
Old 10-12-2011, 12:08 PM   #8
iomari
Zealot
iomari doesn't litteriomari doesn't litter
 
iomari's Avatar
 
Posts: 134
Karma: 100
Join Date: Aug 2003
Location: Nigeria
Device: galaxy tab
Starson17 how do I access your routines? Can't seem to find them under the function list
iomari is offline   Reply With Quote
Old 10-12-2011, 12:25 PM   #9
Starson17
Wizard
Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.
 
Posts: 4,004
Karma: 177841
Join Date: Dec 2009
Device: WinMo: IPAQ; Android: HTC HD2, Archos 7o; Java:Gravity T
Quote:
Originally Posted by iomari View Post
Starson17 how do I access your routines? Can't seem to find them under the function list
See the -c and -e options for calibre-debug: http://manual.calibre-ebook.com/cli/calibre-debug.html

Then you review the code to find the routines you need. Try searching here for posts by Kovid about "calibre-debug -c" or -e to see some examples. Of course, you have to be more careful doing things that way than using calibredb, so make sure you need to run custom code or access low level code before going down that road.
Starson17 is offline   Reply With Quote
Old 10-12-2011, 12:30 PM   #10
iomari
Zealot
iomari doesn't litteriomari doesn't litter
 
iomari's Avatar
 
Posts: 134
Karma: 100
Join Date: Aug 2003
Location: Nigeria
Device: galaxy tab
Thanks.
iomari 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
calibredb list no subseries_index reup Library Management 5 10-11-2011 11:32 AM
calibredb iomari Calibre 6 10-10-2011 09:35 AM
Equality searches via the calibredb 'list' option mobichuck Library Management 10 03-21-2011 05:54 PM
calibredb update bug with 0.7.21? _Em Calibre 1 10-02-2010 05:20 PM
calibredb list --output-format=xml no longer supported Mekk Library Management 6 06-11-2010 09:13 AM


All times are GMT -4. The time now is 01:28 PM.


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