-
Notifications
You must be signed in to change notification settings - Fork 0
/
keynoteCDX.sh
70 lines (54 loc) · 1.51 KB
/
keynoteCDX.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
#!/bin/bash
echo ""
echo "======================================"
echo "=== Keynote -> CDX; .pict format ==="
echo "=== 2020 Maskeri ==="
echo "======================================"
echo ""
echo "Attempts to find embedded CDX data in embedded Keynote 09-style OSX .pict files."
echo ""
if [ -z ${1} ]
then
echo "!!! No input provided. Consumes as input name of Keynote '09 file as only argument."
echo ""
exit
fi
DIR=`uuidgen`
INFILE=${1}
mkdir ${DIR}
echo "... Provided input file: \"${INFILE}\""
echo ""
echo "... CDX data parsed from .pict files will be placed in directory \"${INFILE%.*}_cdxFromPict/\" if .pict files are located"
echo ""
echo "... Working directory \"${DIR}\" will be removed on clean exit."
echo ""
mkdir -p ${INFILE%.*}_cdxFromPict/
cp ${INFILE} ${DIR}/
cd ${DIR}/
mv ${INFILE} ${INFILE}.zip
echo "... Unzipping ${INFILE}"
echo ""
unzip -q ${INFILE}.zip
PICTS=`ls *.pict`
if [ -z "${PICTS}" ]
then
echo "!!! No embedded .pict files located. Attempt other methods of CDX/CDXML recovery or remake graphics."
echo ""
exit
fi
echo "... .pict files located; attempting recovery"
echo ""
for PICT in ${PICTS}
do
sed -n '/VjCD0100/,$p' ${PICT} | perl -pe 's/.*(VjCD0100)/$1/' > ${PICT%.*}.cdx
done
echo "... Cleaning up and removing files of zero size"
echo ""
find . -type f -empty -delete
NUMFOUND=`ls *.cdx | wc -l`
mv *.cdx ../${INFILE%.*}_cdxFromPict/
cd ..
rm -r ${DIR}
echo "... Recovered ${NUMFOUND} .cdx file(s) from ${INFILE}"
echo ""
echo "... done"