According to the
shp2pgsql help, the options drop, append, create and prepare are mutually exclusive. So, if I want to create a table from a shape and then append multiple other shapefiles, I do something like the following, keeping a counter to indicate whether we are in create or append mode.
cnt=0 for shp in $(ls *.shp); do if [ $cnt -eq 0 ] ; then shp2pgsql -s 27700 -c $shp schema.table_name | psql -h localhost db else shp2pgsql -s 27700 -a $shp schema.table_name | psql -h localhost db fi ((cnt++)) done
This works, as expected, but I have often wondered if there is a simpler way?