blob: 0e740176683c71e073d3bf08d47ff6ba5dafbcbe (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
Remove empty folders in offlineimap
###################################
:date: 2019-01-31 16:00
:tags: offlineimap
Offlineimap becomes quite slow when you have so many (empty folders), this is
how you can delete them.
The blog post is based on a (now offline) article_ by Matt Palma.
**Disclaimer:**
Besure to double and triple check every command, actions on the remote
are permanent.
If you want to read more about the dangers of deleting stuff, read the
Matt Palmers article_.
Find all empty folders
----------------------
.. code-block:: bash
cd Mail/ # or wherever you put your Mails
for i in INBOX.*; do find "$i" -type f | grep -q "$i" || \
(echo "$i" ); done >/tmp/empties
cat /tmp/empties
Review the file list
Remove empty folders locally
----------------------------
.. code-block:: bash
cat /tmp/empties | while read i ;do
rm -rvf "$i"
done
The code snippet supports folders with spaces.
Remove empty folders via offlineimap remotely
---------------------------------------------
This is where we use offlineimap instead of logging into the remote server.
.. code-block:: bash
cat /tmp/empties | while read i ;do
offlineimap --delete-folder "$i"
done
.. _article: https://web.archive.org/web/20160810001943/http://www.hezmatt.org/~mpalmer/blog/2007/06/03/offlineimap-and-deleting-folders.html
|