I have an installed library called Gdal which runs certain GIS commands.
This command runs for a single file
gdal_translate -a_srs EPSG:25832 INPUT_FILE OUTPUT_FILE
but I would like to run a batch command which iterates through all *.tif files so I don´t have to write the name of each one (i´ve got 1300 files!)
I tried this in a .sh file…but it didn´t work
#!/bin/bash
for FILE in *.tif
do
BASE=$FILE .tif
NEWFILE=test/${BASE}.tif
gdal_translate -s_srs EPSG:25832 $FILE $NEWFILE
done
could anyone show me how to do this?
yours,
Robert
$FILE includes the
.tifextension. AlsoBASE=$FILE .tifdoesn’t do what you think (it executes.tifwith $BASE set to $FILE for the duration of the command).You also have the difference between
-a_srsand-s_srs. I don’t know which you intended.The end result is, I think, that you want to use
test/$FILEas the output filename.(The quotes make it work with a path with spaces in it. Putting the
foranddoon the same line is a common way of writing it to save space.)