Monday, July 30, 2012

One liner shell command to find and rename to lowercase all SHP, DBF, and SHX file extensions

One liner shell command to find and rename to lowercase all SHP, DBF, and SHX file extensions starting from current directory:

EXTENSIONS="SHP SHX DBF"
for E in $EXTENSIONS ; do export E; export e=`echo $E | tr '[:upper:]' '[:lower:]'`; for f in `find . -name "*.$E"` ; do mv $f `echo $f | sed "s/$E/$e/"`; done  ; done

Useful when you get your shapefiles over from Windows and mapserver won't cooperate.

No comments: