Sign up ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

I have a Maildir structure, that got wrongly restored from backup and all files have the file date of the restore instead of when they have been created/received.

What would be the best way to correct this?

I think about recursively reading the first Received: line, extracting the date and touching the files, but it's a bit above my perl/shell skills. Can someone help?

share|improve this question

1 Answer 1

Something to get you started:

for file in *; do
    echo "Processing $file.."
    tstamp=$(grep "^Date:" $file | cut -d : -f 2)
    echo "Set date to $tstamp"
    # I don't know it the date is in the correct format..   
    touch -d "$tstamp" "$file" 
share|improve this answer
This is a good starting point. But Date-Headers are sometimes forged and are in different timezones. Sometimes the date header is missing. Better look into the topmost Received-Header. – mailq Oct 7 '12 at 13:39

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.