#! /bin/bash
# Last edited on 2024-08-07 11:20:01 by stolfi

# uncompresses all ".zip", ".tgz", and ".gz" files in the current folder.

find ./ \( -name '*.zip' -o -name '*.tgz' -o -name '*.gz' \) -print > .zips

for fp in `cat .zips` ; do 
  echo "=== ${fp} ===" 1>&2; 
  dir="${fp%/*}"; nam="${fp##*/}"; ext="${nam##*.}"
  pushd ${dir} 
    if [[ "/${ext}" == "/zip" ]]; then
      unzip ${nam}
    elif [[ "/${ext}" == "/tgz" ]]; then
      tar -xvzf ${nam}
    elif [[ "/${ext}" == "/gz" ]]; then
      gunzip ${nam}
    else
      echo "** bug ${ext}" 1>&2 ; exit 1
    fi
  popd
done
