```r
## Set the srid, data base and path to the files
srid<-27700
db<-"gis_course"
path<-"rasters/arne"

## Find the names of the files in the path
nms<-dir(path, pattern="tif")

## Add the path to the file names.
fls<-paste(path, nms,sep="/")
## Form table names by adding the name of the schema and dropping the tif extension .
tbls<-paste("arne",gsub(".tif", "", nms),sep=".")

## Loop through all the files adding each one to the schema 
## Using the raster2pgsql command line options
## Sprintf is used to add the appropriate values

for(i in 1:length(fls))
{
com<-sprintf("PGPASSWORD=gis_course123 raster2pgsql -d -s %s %s %s | 
      PGPASSWORD=gis_course123 psql -h postgis -U gis_course -d %s",
      srid,fls[i],tbls[i],db)
system(com)
}
```