Team,
Attached is the script written to find duplicate emails in a mailbox and move them to a backup folder.
This will be helpful in scenarios after migrating or fixing email client-level issues.
The script will maintain its folder hierarchy under the destination folder while moving, making it easy to cross-verify and restore if needed.
Note: Reconstruction of the email box is not included in this script and can be performed later.
Usage :
[root@siddhesh ~]# python3.6 compare_move.py
Usage: python compare_move.py <folder_path> <dest_folder>
[root@siddhesh ~]#
[root@siddhesh ~]# python3.6 compare_move.py /var/spool/imap/a/user/a02/ /tmp/a02_bak/
Emails with common MD5 checksums:
['/var/spool/imap/a/user/a02/138.', '/var/spool/imap/a/user/a02/203', '/var/spool/imap/a/user/a02/203.']
['/var/spool/imap/a/user/a02/140.', '/var/spool/imap/a/user/a02/202.']
Moved: /var/spool/imap/a/user/a02/203 to /tmp/a02_bak/203
Moved: /var/spool/imap/a/user/a02/203. to /tmp/a02_bak/203.
Moved: /var/spool/imap/a/user/a02/202. to /tmp/a02_bak/202.
[root@siddhesh ~]#
Was this article helpful?
That’s Great!
Thank you for your feedback
Sorry! We couldn't be helpful
Thank you for your feedback
Feedback sent
We appreciate your effort and will try to fix the article