![]() |
#1 |
Zealot
![]() ![]() Posts: 146
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 06:31 AM. |
![]() |
![]() |
![]() |
#2 | ||
Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 4,004
Karma: 177841
Join Date: Dec 2009
Device: WinMo: IPAQ; Android: HTC HD2, Archos 7o; Java:Gravity T
|
Quote:
Quote:
|
||
![]() |
![]() |
Advert | |
|
![]() |
#3 |
US Navy, Retired
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 9,896
Karma: 13806776
Join Date: Feb 2009
Location: North Carolina
Device: Icarus Illumina XL HD, Kindle PaperWhite SE 11th Gen
|
I'm ignorant and have never done this, but don't you have to use #supercat vice supercat?
|
![]() |
![]() |
![]() |
#4 | |
Zealot
![]() ![]() Posts: 146
Karma: 100
Join Date: Aug 2003
Location: Nigeria
Device: galaxy tab
|
Quote:
-> 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 09:50 AM. |
|
![]() |
![]() |
![]() |
#5 |
Zealot
![]() ![]() Posts: 146
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. :-) |
![]() |
![]() |
Advert | |
|
![]() |
#6 | |||
Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 4,004
Karma: 177841
Join Date: Dec 2009
Device: WinMo: IPAQ; Android: HTC HD2, Archos 7o; Java:Gravity T
|
@dwanthny: I thought that was the correct syntax, too. It didn't work, but this did:
Quote:
Quote:
Quote:
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. |
|||
![]() |
![]() |
![]() |
#7 |
Zealot
![]() ![]() Posts: 146
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 11:02 AM. |
![]() |
![]() |
![]() |
#8 |
Zealot
![]() ![]() Posts: 146
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
|
![]() |
![]() |
![]() |
#9 | |
Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 4,004
Karma: 177841
Join Date: Dec 2009
Device: WinMo: IPAQ; Android: HTC HD2, Archos 7o; Java:Gravity T
|
Quote:
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. ![]() |
|
![]() |
![]() |
![]() |
#10 |
Zealot
![]() ![]() Posts: 146
Karma: 100
Join Date: Aug 2003
Location: Nigeria
Device: galaxy tab
|
Thanks.
|
![]() |
![]() |
![]() |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
calibredb list no subseries_index | reup | Library Management | 5 | 10-11-2011 10:32 AM |
calibredb | iomari | Calibre | 6 | 10-10-2011 08:35 AM |
Equality searches via the calibredb 'list' option | mobichuck | Library Management | 10 | 03-21-2011 04:54 PM |
calibredb update bug with 0.7.21? | _Em | Calibre | 1 | 10-02-2010 04:20 PM |
calibredb list --output-format=xml no longer supported | Mekk | Library Management | 6 | 06-11-2010 08:13 AM |