0

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?

perler
  • 531
  • 2
  • 6
  • 10

1 Answers1

1

Something to get you started:

#/bin/bash 
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" 
done
Jure1873
  • 3,702
  • 1
  • 22
  • 28
  • 1
    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 07 '12 at 13:39