Created
February 20, 2016 18:09
-
-
Save noah/0626c9d550e19db57d62 to your computer and use it in GitHub Desktop.
offlineimap-rm: remove mail directories, including offlineimap metadata
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
user=noah | |
MDIR=~/mail | |
ODIR=~/.offlineimap | |
A=Account-$user/LocalStatus | |
RL=Repository-Local/FolderValidity | |
RR=Repository-Remote/FolderValidity | |
for mf; do | |
if [ ! -d "$mf" ]; then | |
echo "$mf does not exist or is not a directory" | |
exit -1 | |
fi | |
read -p "Delete the mail folder \`$mf\` from offlineimap cache? [y/n] " -n 1 -r | |
echo | |
mf=$(basename "$mf") | |
if [[ $REPLY =~ ^[Yy]$ ]]; then | |
rm -rf "$ODIR/$A/$mf" | |
rm -rf "$ODIR/$RL/$mf" | |
rm -rf "$ODIR/$RR/$mf" | |
rm -rf "$MDIR/$mf" | |
echo "NOTE: delete \`$mf\` from remote IMAP server before syncing." | |
else | |
echo "skipped \`$mf\`" | |
fi | |
done | |
echo; echo; echo "Final step: empty IMAP trash and run offlineimap." |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment