Skip to content

Instantly share code, notes, and snippets.

@I82Much
Created May 6, 2011 22:01
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save I82Much/959880 to your computer and use it in GitHub Desktop.
This script unzips a kmz file by renaming it to .rar and then calling unzip on it.
#!/bin/sh
# Author: Nick Dunn
#
# This script takes as input the path to a .kmz file and outputs a directory
# full of the contents of that .kmz file, named the same as the .kmz file without
# the kmz suffix. Thus
# ./openkmz.sh /path/to/mykmz.kmz
# would result in a new directory being created at /path/to/mykmz filled with the contents
# of mykmz.kmz.
if [ $# -ne 1 ]
then
echo "Syntax: $0 <kmzfilepath>"
exit
fi
# http://stackoverflow.com/questions/592620/check-if-a-program-exists-from-a-bash-script
type -P unzip &>/dev/null || { echo "I require unzip but it's not installed. Aborting." >&2; exit 1; }
# name without extension
base_name=${1%\.*}
with_rar_ext=${base_name}.rar
echo "Copying $1 to $with_rar_ext"
cp $1 $with_rar_ext
echo "Unzipping"
unzip $with_rar_ext -d $base_name
echo "Cleaning up"
rm $with_rar_ext
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment