I wrote a script to convert DocumentsToGo pdb files into .doc files. I thought someone might find it useful, or might be able to include it in a kdepim plugin or something, so I'm posting it here:
[code:1]
#!/bin/sh
# This program is released under the GPL, except that I don't know how
# to do it. If anyone wants to include the proper GPL block here, be
# my guest.
# Author: Erich Enke
# twilit77@fastmail.fm
#
# suggested program name and usage : pdb2doc infile [outfile]
#
# This program takes in a pdb filename, parses the record list, and
# extracts the file from it. The file doesn't necessarily have to be
# a DocumentsToGo file, but that is all I have tested it with. pdb2doc
# doesn't even care if its a MSWD type of pdb file.
#
# Anyway, it seems no one out there had written anything like this, and
# my wife needed her doc files, so I wrote one up. I hope it does someone
# some good. Who knows? Maybe someone will include it in a kdepim plugin
# or something...
#
# There are several things that could be improved with it:
# 1. a.pdb should have an automatic output filename of a.doc, not a.pdb.doc
# 2. I don't know if the different "sections" of a pdb file should be
# different Word docs. I haven't even tried it yet. (By "sections" I
# mean contiguous lists of all about 4K in length, then it jumps id
# right after a <4K record, and on to a new section...)
# 3. Usage string
# 4. Options parsing
pdb=$1
outfile=${2:-"$pdb.doc"}
function read_addr () {
hexdump -e '12/1 "%02x"' -s $1 -n 3 $pdb | sed 's/^/0x/' | xargs printf "%d"
}
function extract_portion () {
byteskip=$1
bytecount=$2
dd if=$pdb of=.pdb2doc.tmp bs=1 skip=$((byteskip+8)) count=$((bytecount-8)) 2>/dev/null 1>&2
cat .pdb2doc.tmp >> $outfile
rm .pdb2doc.tmp
}
next_addr_bytes=79
skip=`read_addr $next_addr_bytes`
while [ $skip -ne 382 ]; do
echo -n "Doing Record at $skip bytes..."
next_addr_bytes=$((next_addr_bytes + 8))
lastskip=$skip
skip=`read_addr $next_addr_bytes`
if [ $skip -eq 382 ]; then
size=$((`wc -c $pdb | awk '{print $1}'` - lastskip))
else
size=$((skip-lastskip))
fi
extract_portion $lastskip $size
echo " $size bytes processed"
done
[/code:1]
Hope it helps someone,
Erich