R: [GRASS-user] import multiple shapefiles automatically

Nikos Alexandris nikos.alexandris at felis.uni-freiburg.de
Thu Jun 19 08:43:17 EDT 2008


On Thu, 2008-06-19 at 14:40 +0200, Martin Wegmann wrote:
> On Donnerstag, 19. Juni 2008 14:30:45 marco.pasetti at alice.it wrote:
> > >is there a way to tell GRASS to import all the shapefiles in a certain
> > > folder (I've tried *.shp but it didn't work), and give each output map
> > > the same name as the original shapefile?
> >
> > v.in.ogr 'dsn=C:\QGIS\species_shapefiles'
> >
> 
> haven't tried this before, but sounds great, alternatively you can try it with 
> a script:
> 
> #!/bin/bash
> 
> echo "import shape files"
> for i in *.shp ; do
> 	base = ${i%.*} #I found this in my old code, no idea why ,-)
> 	v.in.ogr  input=$i output=$i
> done
> 
> the shell need to be run in the folder with you shp files.
> 
> Martin


Or in one line instead of a script:
for i in *.shp; do v.in.ogr dsn=$i out=`basename $i .shp`; done





More information about the grass-user mailing list