![]() |
#1 |
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 6,939
Karma: 27060151
Join Date: Apr 2009
Location: USA
Device: iPhone 15PM, Kindle Scribe, iPad mini 6, PocketBook InkPad Color 3
|
Auto-remove empty .sdr folders from Kindle?
I wonder if it would be possible to have an option to remove the empty .sdr folders when calibre connects to a Kindle. It seems these never get cleaned up, short of Reset.
|
![]() |
![]() |
![]() |
#2 |
creator of calibre
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 45,345
Karma: 27182818
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
Whenever calibre deletes things itself, it removes empty folders. If you manage files outside of calibre on your kindle then calibre is not going to clean up for you since that would require a full scan of all folders on the device to find empty folders.
|
![]() |
![]() |
Advert | |
|
![]() |
#3 | |
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 6,939
Karma: 27060151
Join Date: Apr 2009
Location: USA
Device: iPhone 15PM, Kindle Scribe, iPad mini 6, PocketBook InkPad Color 3
|
Quote:
And while they can appear elsewhere, that's only when I've side loaded without using calibre and just dropped them in /documents. I don't do it a lot so can just clean those when I notice them. |
|
![]() |
![]() |
![]() |
#4 |
creator of calibre
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 45,345
Karma: 27182818
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
That might be sufficient for you but it wouldnt be sufficient in general and I dont want to implement things in half baked ways.
|
![]() |
![]() |
![]() |
#5 | |
Resident Curmudgeon
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 79,741
Karma: 145864619
Join Date: Nov 2006
Location: Roslindale, Massachusetts
Device: Kobo Libra 2, Kobo Aura H2O, PRS-650, PRS-T1, nook STR, PW3
|
Quote:
For example, the Kobo Utilities plugin has an option to remove leftover covers that aren't being used. |
|
![]() |
![]() |
Advert | |
|
![]() |
#6 |
Well trained by Cats
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 31,047
Karma: 60358908
Join Date: Aug 2009
Location: The Central Coast of California
Device: Kobo Libra2,Kobo Aura2v1, K4NT(Fixed: New Bat.), Galaxy Tab A
|
Look at Quality Check Plugin.
Over a decade ago, Kiwidude added Fix: Cleanup files and folders Since all plugins are mainly ZIP folders, you can look at / tweak the code as needed |
![]() |
![]() |
![]() |
#7 | |
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 6,939
Karma: 27060151
Join Date: Apr 2009
Location: USA
Device: iPhone 15PM, Kindle Scribe, iPad mini 6, PocketBook InkPad Color 3
|
Quote:
I'm sure I've noticed this before, and just shrugged it off. But for some reason now I cannot not see them every time I go into look at what is on there, and I find it annoying. Chalk it up to retirement, my attention latches on to trivial things and magnifies them. It is not even just Kindles with this issue. I plugged in my Pocketbook Era, and it has folders devoid of content, with orphaned .sdr folders as well as completely empty folders (this is in the folder managed by calibre). In the grand scheme of things not a big deal. But it would feel good if there were a Clean Up button somewhere. Last edited by tomsem; 05-30-2023 at 11:36 PM. |
|
![]() |
![]() |
![]() |
#8 |
creator of calibre
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 45,345
Karma: 27182818
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
Since the kindle just appears as a a disk it should be trivial to write a script that scans and deletes all empty folders on it. In fact here is one:
Code:
import os, sys, contextlib def rmdir(x): with suppress(OSError): os.rmdir(x) for (dirpath, dirnames, filenames) is os.walk(sys.argv[1]): for x in dirnames: rmdir(os.path.join(dirpath, x)) calibre-debug clean.py E:/ replace E:/ with the drive your kindle is mounted as. |
![]() |
![]() |
![]() |
#9 | |
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 6,939
Karma: 27060151
Join Date: Apr 2009
Location: USA
Device: iPhone 15PM, Kindle Scribe, iPad mini 6, PocketBook InkPad Color 3
|
Quote:
|
|
![]() |
![]() |
![]() |
#10 |
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 6,939
Karma: 27060151
Join Date: Apr 2009
Location: USA
Device: iPhone 15PM, Kindle Scribe, iPad mini 6, PocketBook InkPad Color 3
|
Turns out it is not as simple as removing empty folders, though that takes care of most of the lint. (This will also delete empty non-.sdr folders, but that's probably a plus, or at least not likely to cause trouble.)
What is left over are some 'orphaned' (non empty) .sdr folders and temporary files with file extensions of pattern r"tmp\d*_(ASC|PHL)". I'm working on a standalone version that handles these. |
![]() |
![]() |
![]() |
#11 | |
Resident Curmudgeon
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 79,741
Karma: 145864619
Join Date: Nov 2006
Location: Roslindale, Massachusetts
Device: Kobo Libra 2, Kobo Aura H2O, PRS-650, PRS-T1, nook STR, PW3
|
Quote:
|
|
![]() |
![]() |
![]() |
#12 |
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 6,939
Karma: 27060151
Join Date: Apr 2009
Location: USA
Device: iPhone 15PM, Kindle Scribe, iPad mini 6, PocketBook InkPad Color 3
|
This is what I came up with (not tested on Windows or Linux):
PHP Code:
It runs almost instantaneously, so I don't see any particular penalty to running it every time you plug Kindle in. I haven't seen the tmp files except on one of my Kindles, so it's possible there are other patterns to look for. I saw updates/ folder on a couple of them, with an .sdr folder inside. Not sure what it is for, but thought it best to leave it alone. I think only /documents needs to be a target for cleanup. I would leave it to user to clean up screen captures in root, for example. And I haven't seen any 'turds' in .documents folder so far (Scribe). [Update] re-factored to use (preferred in Python 3) pathlib. Last edited by tomsem; 06-22-2023 at 10:17 PM. |
![]() |
![]() |
![]() |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
.sdr folders generated from opened PDF files | productivity01 | KOReader | 1 | 06-30-2022 02:39 PM |
Import Data sees new empty folders as not empty | mivetters | Library Management | 6 | 12-21-2019 03:18 PM |
Hide or put all the .sdr folders in one place | poorconsumer | KOReader | 6 | 11-20-2018 09:38 AM |
Librarian Sync creates empty collections folders on Kindle | Trups | Kindle Developer's Corner | 3 | 01-26-2017 08:38 AM |
.SDR folders empty when loading MOBI covers on Kindle Paperwhite | abarnard | Library Management | 1 | 12-25-2012 09:57 PM |