SHARE
TWEET

Untitled

a guest Jul 16th, 2019 67 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. for f in *.smtp.x14.eu_2,S; do
  2. #sed "9q;d" $f
  3. #tail -n+9 $f | head -n1
  4. mv -- "$f" "${f%.smtp.x14.eu_2,S}.eml";
  5. done
  6.      
  7. subj=$(sed -n '/^Subject: PD *//!d;p;q;/^$/q' "$f")
  8.      
  9. subj=$(./emailsubj.py "$f")
  10.      
  11. #!/usr/bin/env python
  12. from email.parser import Parser
  13. from email.header import Header, decode_header
  14. from sys import argv
  15.  
  16. for filename in argv[1:]:
  17.     with open(filename, 'rb') as handle:  # handle file not found etc?
  18.         message = Parser().parse(handle)
  19.     try:
  20.         subj = ''.join([frag.decode(enc) if enc else frag
  21.             for frag, enc in decode_header(message['subject'])])
  22.     except HeaderParseError, UnicodeDecodeError:
  23.         subj = message['subject']   # maybe warn about error?
  24.     print(subj)
  25.      
  26. echo "${subj#PD: )"
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top