Skip to content

Instantly share code, notes, and snippets.

@rbanick
Last active August 29, 2015 14:08
Show Gist options
  • Save rbanick/4edb371f95819bae1aef to your computer and use it in GitHub Desktop.
Save rbanick/4edb371f95819bae1aef to your computer and use it in GitHub Desktop.
Batch GDAL

Bash script for batch GDAL processes. This example ogr2ogr converts from .shp to .geojson.

#!/bin/bash

for FILE in *.shp # cycles through all files in directory (case-sensitive!)
do
    echo "converting file: $FILE..."
    FILENEW=`echo $FILE | sed "s/.shp/_new.geojson/"` # replaces old filename
    ogr2ogr \
    -f "GEOJson" \
    $FILENEW $FILE
done
exit
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment