Last active
April 11, 2017 10:30
-
-
Save ffflorian/c1731b86755aa6fc7511fc25009cf7de to your computer and use it in GitHub Desktop.
Convert multiple kmz files to kml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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