dotfiles
My PC Dotfiles & Websitegit clone https://github.com/maydayv7/dotfiles
scripts/mail.sh (1068B)
1#! /usr/bin/env nix
2#! nix shell nixpkgs#bash nixpkgs#coreutils nixpkgs#gnused nixpkgs#libpst -c bash
3
4# Script to convert '.pst' Files to '.mbox' #
5
6MAIL=./convert-$(date '+%H-%M_%d-%m-%y')
7
8# File Conversion
9read -rp "Enter Path to '.pst' File: " DIR
10echo "Converting '.pst' to '.mbox'"
11mkdir "$MAIL" && readpst -o "$MAIL" -r "$DIR"
12find "$MAIL" -type d -mindepth 1 | tac | xargs -d '\n' -I{} mv {} {}.sbd
13find "$MAIL" -name mbox -type f | xargs -d '\n' -I{} echo '"{}" "{}"' | sed -e 's/\.sbd\/mbox"$/"/' | xargs -L 1 mv
14find "$MAIL" -empty -type d | xargs -d '\n' rmdir
15find "$MAIL" -type d | grep -E '.sbd' | sed 's/.\{4\}$//' | xargs -d '\n' touch
16echo "Conversion complete, files are present in $MAIL"
17
18# Mail Import
19import() {
20read -rp "Enter name of Thunderbird Profile: " PROFILE
21cp -r "$MAIL"/. "$HOME/.thunderbird/$PROFILE/Mail/Local Folders/Converted/" && echo "Successfully Imported"
22}
23
24read -rp "Do you want to import the Mails into Thunderbird? (Y/*): " choice
25 case $choice in
26 [Yy]*) import; rm -rf "$MAIL";;
27 *) rm -rf "$MAIL"; exit;;
28 esac