While setting up a self refilling test mail server, I came across the problem that I need other IMAP INTERNALDATEs (aka arrival date) than the create/modify time of the email file.
As my email generator script creates random dates for the email headers that are between 10 years back and today, it would make perfect sense to also use them as the arrival date of the message.
Five minutes later the following little script was finished, which I think could be pretty useful for anyone who has to update the arrival date in his IMAP server that uses Maildir format or similar. This could for instance become quite handy after an email migration where the IMAP INTERNALDATE could not be retained.
#!/bin/sh for FILE in `find $1 -type f` do DATE=`grep "Date" $FILE | cut -d ":" -f 2- | sed -e 's/^ *//g' -e 's/ *$//g'` if [ -n "$DATE" ] then echo "Setting modified time of \"$FILE\" to \"$DATE\"." touch -c $FILE --date="$DATE" else echo "No date found in \"$FILE\"." fi done