Last active
October 13, 2015 08:58
-
-
Save oeon/4171529 to your computer and use it in GitHub Desktop.
Add column with source filename from folder of shapefiles. Requires GDAL 1.10dev, my attempt to drop .shp extension isn't working - but overall, works.
This file contains 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
for f in *.shp; | |
do | |
name=${f%.shp} | |
/Users/you/gdal_trunk/bin/ogrinfo $f -sql "ALTER TABLE $name ADD COLUMN filename character(21)" | |
/Users/you/gdal_trunk/bin/ogrinfo $f -dialect SQLite -sql "UPDATE $name SET filename = '$f'" | |
done; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment