[FWTools] batch gdal_translate ??

Matt Wilkie matt.wilkie at gov.yk.ca
Thu Jul 31 12:42:10 EDT 2008


Hi Garret,

Interactively on the command line, this will search all subdirectories 
and create a .jpg in the same place as each .sid:

    for /r %g in (*.sid) do gdal_translate -of jpeg "%g" "%~dpng.jpg"

the '/r' means recursive,
the g in '%g' can be any letter,
the '%~n' means use only the name, 'p' is path, 'd' is drive letter
the quotes "" are for embedded spaces etc.

To test your command before running, preface with '@echo'

    ...do @echo gdal_translate ...

In a batch file, double up the percents '%%g':

    for /r %%g ... do ..%%g %%~dpng.jpg

more resources here:
http://www.ss64.com/nt/for_r.html
http://www.ss64.com/ntsyntax/parameters.html

cheers,

matt wilkie
--------------------------------------------
Geographic Information,
Information Management and Technology,
Yukon Department of Environment
10 Burns Road * Whitehorse, Yukon * Y1A 4Y9
867-667-8133 Tel * 867-393-7003 Fax
http://environmentyukon.gov.yk.ca/geomatics/
--------------------------------------------


Garret Wais wrote:
> Hello,
> I would like to create a bat file for gdal_translate.  I have about one 
> thousand sid files that I would like to convert to jpg, I know I can 
> use, "gdal_translate -of JPEG FILENAME.sid OUTPUT.jpg" to do this but 
> doing that 1000 X's would not be efficient (or fun). 
> I know there is a way to write something like:
> 
> for file in *
> do input=`echo $file
> etc etc.
> 
> I just cant remember exactly how it should be written.  If anyone can 
> help that would be great.
> 
> thank you,
> Garret
> 
> 
> ------------------------------------------------------------------------
> 
> _______________________________________________
> FWTools mailing list
> FWTools at lists.maptools.org
> http://lists.maptools.org/mailman/listinfo/fwtools
> http://fwtools.maptools.org/



More information about the FWTools mailing list