<html><head><meta http-equiv="Content-Type" content="text/html charset=us-ascii"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div>I have tried these three methods to add a filename column while scripting a folder of shapefiles, with a Bash script - which results in `Warning 6: Normalized/laundered field name` & `ERROR 1: SQL Expression Parsing Error: syntax error` messages and NULL values in the created column :</div><div><br></div><div>#1<br><br>for f in *.shp;<br><br>do<br><br>name=${f%.shp}<br><br>ogrinfo $f -sql "ALTER TABLE $name ADD COLUMN filename character(10)"<br>ogrinfo $f -sql "UPDATE TABLE $name filename = '$f'"<br>done;<br><br>#2<br><br>for f in *.shp;<br><br>do<br><br>name=`echo "$f"|sed 's/\.shp$//g'`<br><br>ogrinfo $f -sql "ALTER TABLE $name ADD COLUMN filename character(10)"<br>ogrinfo $f -sql "UPDATE TABLE $name filename = '$f'"<br>done;<br><br>#3<br><br>for f in *.shp;<br><br>do<br><br>name=`basename $f .shp`<br><br>ogrinfo $f -sql "ALTER TABLE $name ADD COLUMN filename character(10)"<br>ogrinfo $f -sql "UPDATE TABLE $name filename = '$f'"<br>done;</div><div><br></div><div><br></div><div>There's an example here <a href="http://trac.osgeo.org/gdal/wiki/FAQVector">http://trac.osgeo.org/gdal/wiki/FAQVector</a> called "How do I include the source filename in a field when merging hundreds of shapefiles (Windows)?" I also cannot get this to work - getting "unrecognized fieldname" message.</div><div><br></div><div>Perhaps my variable does not work in the Bash SQL statement. I'm not sure what's going on in the Windows example.</div><div><br></div><div>Regards,</div><div>Joe Larson</div></body></html>