Skip to content

Instantly share code, notes, and snippets.

@lukasmartinelli
Created July 30, 2016 12:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lukasmartinelli/402a056168606a513d593fb34a94b80d to your computer and use it in GitHub Desktop.
Save lukasmartinelli/402a056168606a513d593fb34a94b80d to your computer and use it in GitHub Desktop.
Compress all DEM TIFF files in a directory in place
#!/bin/bash
set -o errexit
set -o pipefail
set -o nounset
function compress_inplace() {
local filename="$1"
gdal_translate -co compress=lzw "$filename" "$filename.compressed"
rm "$filename"
mv "$filename.compressed" "$f"
}
function compress_files() {
local source_dir="$1"
for f in $source_dir/*.tif; do
compress_inplace "$f"
done
}
compress_files "$1"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment