[Gdal-dev] Batch export from a directory?
Ivan Lucena
ILucena at clarku.edu
Mon Mar 27 09:26:22 EST 2006
Hi Jonathan,
As far as I can remember from the Science Data Processing Workshops, you
guys don't use Windows quite often at Greenbelt, but just in case you
are using Windows, you can open the Command Prompt and time this DOS
instruction:
C:\Data > for %i in (*.tif) do gdal_translate -of hfa %i %~ni.img
For more info type:
C:\Data > help for
Ivan Lucena
-----Original Message-----
From: gdal-dev-bounces at lists.maptools.org
[mailto:gdal-dev-bounces at lists.maptools.org] On Behalf Of Matthew Perry
Sent: Saturday, March 25, 2006 8:05 PM
To: Jonathan Greenberg
Cc: gdal-dev at lists.maptools.org
Subject: Re: [Gdal-dev] Batch export from a directory?
Jonathan,
On 3/25/06, Jonathan Greenberg <jgreenberg at arc.nasa.gov> wrote:
> Is there a way to select a directory and batch export using gdal all
> workable image files to a single output format (modifying the
extension as
> necessary?)
>
If you're using a bash shell, you might try a script along these lines:
====================
outputdir=/home/newdata
inputdir=/home/data
cd $inputdir
for raster in *; do
gdalinfo $raster
# If gdalinfo returned exit code 0,
# we can assume its a valid raster image
if [ $? = 0 ]; then
# Assume the file prefix is everything before the first '.'
prefix=` echo $raster | sed 's/\..*//'`
# use gdal_translate to convert to ERDAS Imagine format
gdal_translate -of "HFA" $raster ${outputdir}/${prefix}.img
fi
done
=====================
--
Matt Perry
perrygeo at gmail.com
http://www.perrygeo.net
_______________________________________________
Gdal-dev mailing list
Gdal-dev at lists.maptools.org
http://lists.maptools.org/mailman/listinfo/gdal-dev
More information about the Gdal-dev
mailing list