how to convert batch file from .tif to .bil format using gdal_translate in windows CMD command line, file in the directory.

Directory path : D:\GDAL-TEST
So on....

I have one code but by this code we can convert single file at a time but i want to loop through all raster which have .tif extension in the directory and convert it to .bil format. Please want a solution

My code. I a running this code on GDAL Command window on windows 7 platform.

gdal_translate -of "ENVI" D:\GDAL-TEST\001_mean.tif D:\GDAL-TEST\001_mean.bil

1 Answer 1


From the command line you can write

for %i in (*.tif) do gdal_translate -of "ENVI" %i %i.bil

The command above will convert all tif to bil in the actual directory. The output name will be some_name.tif.bil. From a batch (.bat) file you must use double percent sign for variables.

for %%i in (*.tif) do gdal_translate -of "ENVI" %%i %%i.bil

If you would like to remove .tif from the output file name you see the following https://stackoverflow.com/questions/3215501/batch-remove-file-extension

  • 1
    for %%i in (*.tif) do gdal_translate -of "ENVI" %%i %%~ni.bil should deliver the right filenames. Assuming that the batch is in the same folder as the tif files, and gdal_translate somewhere in the PATH variable.
    – AndreJ
    Commented Aug 28, 2016 at 8:36

Not the answer you're looking for? Browse other questions tagged or ask your own question.