Skip to content

Instantly share code, notes, and snippets.

@nvkelso
Created August 1, 2012 06:16
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 nvkelso/3224210 to your computer and use it in GitHub Desktop.
Save nvkelso/3224210 to your computer and use it in GitHub Desktop.
#!/bin/bash
# loop through all of the shapefiles in the directory and act on them
# http://trac.osgeo.org/gdal/wiki/FAQVector#HowcanImergehundredsofShapefiles
# http://stackoverflow.com/questions/965053/extract-filename-and-extension-in-bash
#USAGE:
# sh list_dir_of_shps.sh in_dir_path out_dir_path
#Capture the shell arguments
in_dir_of_shps=$1
out_dir_of_shps=$2
#Ensure the output directory exists
mkdir -p ${out_dir_of_shps}
#Loop thru all the shps in the input dir
for i in $(ls ${in_dir_of_shps}/*.shp); do
echo ${i}
#Capture each filename
filename=$(basename "$i")
#extension="${filename##*.}"
#filename="${filename%.*}"
o=${out_dir_of_shps}/${filename}
#echo ${o}
python ../ogrtools.py --in_file ${i} --out_file ${o} --function fieldnames_lowercase
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment