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
9 if [ -e "${TEMP_FOLDER}" ]; then
10 rm -rf "${TEMP_FOLDER}"
13 mkdir
-p "${TEMP_FOLDER}"
18 find "${1}" |
while read FILE
; do
19 if [ "${FILE}" != "${1}" ]; then
27 HASH
=`sha1sum -b "${1}" | sed -e 's/ .*//' -`
30 echo "Error calculating hash for ${DFILENAME}."
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}" ;;
47 find "${SOURCE_FOLDER}" |
sort |
while read FILENAME
; do
48 if [ "${FILENAME}" == "${SOURCE_FOLDER}" ]; then
52 echo "Scanning ${FILENAME}..."
54 # Can figure out text far faster, but doesn't give us the archive info. We do this first, and if it's not text, we try again in detail.
55 # Why does this script even exist? Why don't we do this during download? Why don't we have an "uncompressed" staging area?
56 TYPE
=`file -b -e soft "${FILENAME}"`
59 UTF-8\ Unicode\ text
) continue ;;
60 UTF-8\ Unicode\ English\ text
) continue ;;
61 UTF-8\ Unicode\ text
,\ with\ CRLF\ line\ terminators
) continue ;;
62 UTF-8\ Unicode\ English\ text
,\ with\ CRLF\ line\ terminators
) continue ;;
63 ASCII\ English\ text
) continue ;;
64 ASCII\ English\ text
,\ with\ CRLF\ line\ terminators
) continue ;;
67 TYPE
=`file -b "${FILENAME}"`
70 Zip\ archive
*) unzip "${FILENAME}" -d "${TEMP_FOLDER}" ;;
71 RAR\ archive
*) unrar e
-o- "${FILENAME}" "${TEMP_FOLDER}/" ;;
72 7-zip\ archive
*) 7z e
"-o${TEMP_FOLDER}" "${FILENAME}" ;;
77 echo "${FILENAME} is not an archive."
81 echo "Processing ${FILENAME}..."
83 find "${TEMP_FOLDER}" |
while read DFILENAME
; do
84 if [ "${DFILENAME}" != "${TEMP_FOLDER}" ]; then
92 rm -rf "${TEMP_FOLDER}"