Made purge command reset the locale of the saved data, and added files for 0.44 release.
[QuestHelper.git] / Development / decompress.sh
blobcc118a128fa6bc67635fbd8c2e83b8c0bb20820a
1 #!/bin/bash
3 # Will find all the archives in the current directory, extract the nested lua/archive files from them, and
4 # then delete the archives. At least, that's what it's supposed to do. No promises.
6 SOURCE_FOLDER=LocalInput
7 TEMP_FOLDER=./Temp
9 if [ -e "${TEMP_FOLDER}" ]; then
10 rm -rf "${TEMP_FOLDER}"
13 mkdir -p "${TEMP_FOLDER}"
15 function doFile {
16 if [ -e ${1} ]; then
17 if [ -d ${1} ]; then
18 find "${1}" | while read FILE; do
19 if [ "${FILE}" != "${1}" ]; then
20 doFile ${FILE}
22 done
23 rmdir ${1}
24 else
25 chmod -x "${1}"
27 HASH=`sha1sum -b "${1}" | sed -e 's/ .*//' -`
29 if [ $? != 0 ]; then
30 echo "Error calculating hash for ${DFILENAME}."
31 exit 1
34 TYPE=`file -b "${1}"`
36 case "${TYPE}" in
37 *\ text*) mv -f "${1}" "${SOURCE_FOLDER}/${HASH}.lua" ;;
38 Zip\ archive*) mv -f "${1}" "${SOURCE_FOLDER}/${HASH}.zip" ;;
39 RAR\ archive*) mv -f "${1}" "${SOURCE_FOLDER}/${HASH}.rar" ;;
40 7-zip\ archive*) mv -f "${1}" "${SOURCE_FOLDER}/${HASH}.7z" ;;
41 *) echo "Ignoring '${1}'" ; rm "${1}" ;;
42 esac
47 find "${SOURCE_FOLDER}" | while read FILENAME; do
48 if [ "${FILENAME}" == "${SOURCE_FOLDER}" ]; then
49 continue
52 TYPE=`file -b "${FILENAME}"`
54 case "${TYPE}" in
55 Zip\ archive*) unzip "${FILENAME}" -d "${TEMP_FOLDER}" ;;
56 RAR\ archive*) unrar e "${FILENAME}" "${TEMP_FOLDER}/" ;;
57 7-zip\ archive*) 7z e "-o${TEMP_FOLDER}" "${FILENAME}" ;;
58 *) continue ;;
59 esac
61 if [ $? != 0 ]; then
62 echo "${FILENAME} is not an archive."
63 continue
66 echo "Processing ${FILENAME}..."
68 find "${TEMP_FOLDER}" | while read DFILENAME; do
69 if [ "${DFILENAME}" != "${TEMP_FOLDER}" ]; then
70 doFile "${DFILENAME}"
72 done
74 rm "${FILENAME}"
75 done
77 rm -rf "${TEMP_FOLDER}"
79 echo "Finished."
80 sleep 5
81 exit 0