diff options
author | Dirk Engling <erdgeist@erdgeist.org> | 2015-05-13 02:38:09 +0200 |
---|---|---|
committer | Dirk Engling <erdgeist@erdgeist.org> | 2015-05-13 02:38:09 +0200 |
commit | 19b16fb2b5af35c337209c6f59ea67a5b97c493e (patch) | |
tree | bef756913de72bdd438eab8edb00e6c9507f0bfe | |
parent | 4ab9fe24e79e0ef83afae2ec345e0d5a7b1474f7 (diff) |
Automatize extracting version 2 CDs
-rwxr-xr-x | makecolumns.sh | 28 |
1 files changed, 26 insertions, 2 deletions
diff --git a/makecolumns.sh b/makecolumns.sh index 5d2f1aa..c3f6f95 100755 --- a/makecolumns.sh +++ b/makecolumns.sh | |||
@@ -32,6 +32,8 @@ main() { | |||
32 | handle_format_version_4 "${1}" | 32 | handle_format_version_4 "${1}" |
33 | elif [ -f ${1}/[Dd][Aa][Tt]/[Tt][Ee][Ii][Ll][Nn].[Dd][Aa][Tt] ]; then | 33 | elif [ -f ${1}/[Dd][Aa][Tt]/[Tt][Ee][Ii][Ll][Nn].[Dd][Aa][Tt] ]; then |
34 | handle_format_version_3 "${1}" | 34 | handle_format_version_3 "${1}" |
35 | elif [ -n "`find "${1}" -iname atb?dd00 -ls -quit`" ]; then | ||
36 | handle_format_version_2 "${1}" | ||
35 | elif [ -n "`find "${1}" -name dpr00000.005 -ls -quit`" ]; then | 37 | elif [ -n "`find "${1}" -name dpr00000.005 -ls -quit`" ]; then |
36 | handle_format_version_1 "${1}" | 38 | handle_format_version_1 "${1}" |
37 | else | 39 | else |
@@ -84,7 +86,7 @@ get_dword() { | |||
84 | } | 86 | } |
85 | 87 | ||
86 | handle_format_version_1() { | 88 | handle_format_version_1() { |
87 | echo "Working on $1. Detected pre-02/1996 Telefonbuch version." | 89 | echo "Working on $1. Detected 1992 Telefonbuch version." |
88 | # Extract all dpr database files | 90 | # Extract all dpr database files |
89 | printf "Extracting dpr databases ... " | 91 | printf "Extracting dpr databases ... " |
90 | find "$1" -name dpr\*.001 | extract_version_1 | 92 | find "$1" -name dpr\*.001 | extract_version_1 |
@@ -105,9 +107,31 @@ handle_format_version_1() { | |||
105 | mv 12_unknown 13_Rufnummer | 107 | mv 12_unknown 13_Rufnummer |
106 | mv 13_unknown 11_Ort | 108 | mv 13_unknown 11_Ort |
107 | mv 14_unknown 10_Postleitzahl | 109 | mv 14_unknown 10_Postleitzahl |
108 | |||
109 | } | 110 | } |
110 | 111 | ||
112 | handle_format_version_2() { | ||
113 | echo "Working on $1. Detected pre 02/1996 Telefonbuch version." | ||
114 | |||
115 | # Extract all CD's pkware compressed databases | ||
116 | printf "Extracting 3 pkware databases ...\n" | ||
117 | cd=1 | ||
118 | for database in `find "$1" -iname atb?dd00`; do | ||
119 | dir=`dirname ${database}` | ||
120 | base=`basename ${database}` | ||
121 | printf " %d/3 in %4s. Decompressing ... " ${cd} "$( basename ${dir} )" | ||
122 | extract_version_2 "${database}" > ${base}.dump | ||
123 | |||
124 | printf ", extracting ... " | ||
125 | indexfile=$( find ${dir} -iname atb?di00 ) | ||
126 | split_version_2 "${base}.dump" "${indexfile}" | ||
127 | |||
128 | printf ", cleaning up ... " | ||
129 | rm "${base}.dump" | ||
130 | printf "done.\n" | ||
131 | cd=$((cd+1)) | ||
132 | done | ||
133 | |||
134 | } | ||
111 | 135 | ||
112 | handle_format_version_3() { | 136 | handle_format_version_3() { |
113 | echo "Working on $1. Detected pre-2004 Telefonbuch version." | 137 | echo "Working on $1. Detected pre-2004 Telefonbuch version." |