|
![]() |
|
Thread Tools | Search this Thread |
![]() |
#1 |
Zealot
![]() Posts: 124
Karma: 10
Join Date: Dec 2008
Location: France
Device: None
|
CLI - calibredb export : how to export only books with a specific tag ?
calibre 5.37, Windows 10 21H2
I run regularly a batch file to export all my books. It works great but now I'd like to add a second export, but only for books having a specific tag. Looking at the calibredb doc, I see no options to exclude/include tags. So, is it possible or not ? If not, any work around via the command line ? Thanks. |
![]() |
![]() |
![]() |
#2 | |
Well trained by Cats
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 30,873
Karma: 59840450
Join Date: Aug 2009
Location: The Central Coast of California
Device: Kobo Libra2,Kobo Aura2v1, K4NT(Fixed: New Bat.), Galaxy Tab A
|
Quote:
Code:
calibredb --search tags:<the-tag-list-here> |
|
![]() |
![]() |
Advert | |
|
![]() |
#3 |
Zealot
![]() Posts: 124
Karma: 10
Join Date: Dec 2008
Location: France
Device: None
|
Thanks for your answer.
Unfortunately, no, it doesn't work. There's no --search option in the export command. It would be great to have some kind of filters when exporting. But, you gave me an idea : according to the doc : "calibredb search - The output format is useful to feed into other commands that accept a list of ids as input."" So Code:
calibredb search tags:"my tag" then Code:
calibredb export id1,id2,etc --to-dir "I:\test" Now the problem is, how do I pass this (big!) list of ids to the export command, in a batch file... I'll have to think about it ![]() Thanks ! |
![]() |
![]() |
![]() |
#4 |
Well trained by Cats
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 30,873
Karma: 59840450
Join Date: Aug 2009
Location: The Central Coast of California
Device: Kobo Libra2,Kobo Aura2v1, K4NT(Fixed: New Bat.), Galaxy Tab A
|
Someone who understands my Sig
![]() I pointed you to an idea, you put it together and learned how to do more ![]() |
![]() |
![]() |
![]() |
#5 |
null operator (he/him)
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 21,596
Karma: 29709834
Join Date: Mar 2012
Location: Sydney Australia
Device: none
|
|
![]() |
![]() |
Advert | |
|
![]() |
#6 | |
Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 1,182
Karma: 1306007
Join Date: Dec 2016
Location: Goiânia - Brazil
Device: iPad, Kindle Paperwhite
|
Quote:
Code:
FOR /F "tokens=*" %%g IN ('calibredb search tags:"my tag"') do (SET IDS=%%g) calibredb export %IDS% --to-dir "I:\test" |
|
![]() |
![]() |
![]() |
#7 |
Zealot
![]() Posts: 124
Karma: 10
Join Date: Dec 2008
Location: France
Device: None
|
Thanks.
That's what I ended up doing, using a for loop (the (big!) pipe didn't worked, thanks BetterRed ![]() Now, it's working... partially. One problem remains : some of my tags have spaces in their name, and I get strange results, or no result at all (nothing is exported). For example : "Langue française" In my library, I have 66 books with this tag, only 9 of them are exported. "Littérature étrangère", 1057 books, only one book exported. "Récits de voyages", 67 books, 4 books exported. All other books having a tag with a single word are correctly exported, so I suspect the space in the name to be the culprit ? Code:
set destfolder=I:\test set searchtag="Littérature française" calibre -s del /s /q %destfolder% > nul for /f %%A in ('calibredb search tags:"%searchtag%"') do ( calibredb export %%A ^ --dont-asciiize --dont-save-cover --dont-write-opf ^ --to-dir %destfolder% --progress ^ --template "{author_sort} - {series}{series_index:0>2s| | - } {title}" ) |
![]() |
![]() |
![]() |
#8 |
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 12,311
Karma: 7957679
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
|
You need to escape the quotes with backslashes, like this.
Code:
set searchtag=Alternate history for /f %%A in ('calibredb search tags:\"%searchtag%\"') do (echo %%A) Code:
set searchtag=Alternate history for /f %%A in ('calibredb search tags:\"=%searchtag%\"') do (echo %%A) |
![]() |
![]() |
![]() |
#9 |
Zealot
![]() Posts: 124
Karma: 10
Join Date: Dec 2008
Location: France
Device: None
|
Great !
Now everything's fine. Thanks to all ![]() |
![]() |
![]() |
![]() |
Thread Tools | Search this Thread |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Mimic the Calibre Export Library using CLI | Kevan | Library Management | 4 | 06-15-2020 06:44 PM |
Preferred formats in calibredb export | halloleo | Library Management | 3 | 03-30-2020 03:24 AM |
Calibredb export | phossler | Library Management | 18 | 07-18-2015 07:15 PM |
CalibreDB Export Progress Indication?? | phossler | Calibre | 2 | 01-26-2015 09:02 PM |
Calibredb export: can I do a subset of books (based on a query)? | spedinfargo | Calibre | 6 | 02-25-2014 03:18 PM |