-
Notifications
You must be signed in to change notification settings - Fork 0
/
B-therealfinal-mail.sh
136 lines (105 loc) · 3.04 KB
/
B-therealfinal-mail.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
#/bin/bash
#
# B-therealfinal-email.sh
#
# Search the ASCII plaintext and each of the other components of
# and email. Log any hits, copyinging the sdocument to the files
# directory as normal - but also move the full .eml into files
#
# The log needs to show the hierchacil relationship (ie this file
# is part of email "x".
#
# search strings
#
ss="submarine|"
ss=$ss"bomb|"
ss=$ss"guilty|"
s=$ss"reamer"
echo $ss
# IFS business, because we have filenames
# with spaces in them...
OLDIFS=$IFS
IFS=$'\n'
# created needed directories...
mkdir ClientA-results/mail
mkdir ClientA-results/log
# some headers for the CSV file...
echo "Unique ID" "," "From: date" "," "File" > ClientA-results/log/email-run-$$.csv
# Process each of the .PST files
# twice, first as .EML type single
# files, and secondly with all the
# attachments etc split out.
#
ifile="ClientA/USB-1/PersonA.pst"
ofile1="ClientA-mail/PersonA-emails"
ofile2="ClientA-mail-S/PersonA-emails"
mkdir -p $ofile1
mkdir -p $ofile2
readpst $ifile -o $ofile1 >$ofile1/proc.log
readpst -S $ifile -o $ofile2 >$ofile2/proc.log
ifile="ClientA/USB-1/PersonB.pst"
ofile1="ClientA-mail/PersonB"
ofile2="ClientA-mail-S/PersonB"
mkdir -p $ofile1
mkdir -p $ofile2
readpst $ifile -o $ofile1 >$ofile1/proc.log
readpst -S $ifile -o $ofile2 >$ofile2/proc.log
ifile="ClientA/USB-2/PersonC.pst"
ofile1="ClientA-mail/PersonC"
ofile2="ClientA-mail-S/PersonC"
mkdir -p $ofile1
mkdir -p $ofile2
readpst $ifile -o $ofile1 >$ofile1/proc.log
readpst -S $ifile -o $ofile2 >$ofile2/proc.log
ifile="ClientA/USB-2/PersonD.pst"
ofile1="ClientA-mail/PersonD"
ofile2="ClientA-mail-S/PersonD"
mkdir -p $ofile1
mkdir -p $ofile2
readpst $ifile -o $ofile1 >$ofile1/proc.log
readpst -S $ifile -o $ofile2 >$ofile2/proc.log
ifile="ClientA/USB-3/PersonB/ABC/PersonE/archive.pst"
ofile1="ClientA-mail/archive"
ofile2="ClientA-mail-S/archive"
mkdir -p $ofile1
mkdir -p $ofile2
readpst $ifile -o $ofile1 >$ofile1/proc.log
readpst -S $ifile -o $ofile2 >$ofile2/proc.log
#
# OK, we now have the mail expanded into both
# ClientA-mail and ClientA-main-S - ready for searching
#
# DEBUG can out
ISF=$OLDIFS
exit
# The "TRICK" to finding all the main text body of the emails is this:
#
# find . -regex ".*\/[0-9]{1,4}"
#
folders=$(find
for folder in "PersonA-emails" "ABC-archive" "PersonB" "MTN-archive" "PersonC-inbox" "PersonC-send"
do
echo Processing $folder ...
files=$(find ClientA-intermediate/$folder -type f )
for f in $files
do
file $f |grep ASCII
if [ $? -eq 0 ]
then
egrep -q -i $ss $f
if [ $? -eq 0 ]
then
index=$(stat $f |grep Inode|awk '{print $4}')
filename=$(basename $f)
# copy into the mail folder, with the index number, and append .eml
# so that they're easily opened in Outlook...
#
cp $f ClientA-results/mail/$index-$filename.eml
# and grab the "From:" date from our spreadsheet
fromdate=$(head -20 $f |grep -i ^date:|cut -f 2 -d,|cut -f1-4 -d" ")
echo "$index" "," "$fromdate" "," $f >> ClientA-results/log/email-run-$$.csv
fi
fi
done
done
ISF=$OLDIFS