notetools/md2imap/md2imap.sh

30 lines
631 B
Bash
Raw Normal View History

2024-04-10 17:10:27 +02:00
qp () {
perl -MMIME::QuotedPrint -s -ne '
BEGIN { *e = $d ? \&decode_qp : \&encode_qp }
print e $_
' -- "$@"
}
2024-04-10 15:17:04 +02:00
rm mbox
2024-04-12 13:35:39 +02:00
rm uidmap
2024-04-10 15:17:04 +02:00
for f in input/*.md
do
2024-04-12 13:35:39 +02:00
dos2unix -q "$f"
2024-04-10 15:17:04 +02:00
f=${f##*/}
title=${f%.md}
2024-04-10 17:10:27 +02:00
subject=$(echo $title|qp -e)
2024-04-10 15:17:04 +02:00
uid=$(cat /proc/sys/kernel/random/uuid)
2024-04-12 13:35:39 +02:00
echo $uid $title >> uidmap
2024-04-10 21:44:15 +02:00
cp imap-note-header "$title".header
sed -i "s/name/$1/" "$title".header
sed -i "s/email/$2/" "$title".header
sed -i "s/uid/${uid}/" "$title".header
sed -i "s/title/${subject}/" "$title".header
2024-04-10 15:17:04 +02:00
2024-04-10 21:44:15 +02:00
cat "$title".header >> mbox
2024-04-10 15:17:04 +02:00
printf '\n\n' >> mbox
2024-04-10 21:44:15 +02:00
cat "input/$f" | qp -e >> mbox
rm "$title".header
2024-04-10 15:17:04 +02:00
done