Skip to content

Instantly share code, notes, and snippets.

@ffflorian
Last active April 11, 2017 10:30
Show Gist options
  • Save ffflorian/c1731b86755aa6fc7511fc25009cf7de to your computer and use it in GitHub Desktop.
Save ffflorian/c1731b86755aa6fc7511fc25009cf7de to your computer and use it in GitHub Desktop.
Convert multiple kmz files to kml
#!/usr/bin/env sh
# Convert kmz to kml
# @ffflorian, 2017
# Exit on error
set -eu
if ! command -v "7z" > /dev/null; then
echo >&2 "Could not find 7z. Exiting."
exit 1
fi
# Change file separator temporarily to allow filenames with spaces
OLDIFS=$IFS
IFS=$(printf "\n\b")
for FILE in *.kmz; do
if 7z t "${FILE}" > /dev/null; then
7z e -so "${FILE}" > "${FILE%.*}.kml"
rm "${FILE}"
fi
done
IFS=$OLDIFS
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment