notetools/md2imap/md2imap.sh

26 lines
569 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
for f in input/*.md
do
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)
cp imap-note-header "$title".imap
sed -i "s/uid/${uid}/" "$title".imap
2024-04-10 17:10:27 +02:00
sed -i "s/title/${subject}/" "$title".imap
2024-04-10 15:17:04 +02:00
sed -i "s/name/$1/" "$title".imap
sed -i "s/email/$2/" "$title".imap
2024-04-10 17:10:27 +02:00
cat "input/$f" | qp -e >> "$title".imap
2024-04-10 15:17:04 +02:00
cat "$title".imap >> mbox
printf '\n\n' >> mbox
rm "$title".imap
done