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

closed as off-topic by user30184, PolyGeo Aug 28 '16 at 10:12

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "Questions relating to general Information Technology, with no clear GIS component, are off-topic here, but can be researched/asked at Stack Overflow (software development), Super User (computing hardware and software) and Database Administrators (relational databases)" – user30184, PolyGeo
If this question can be reworded to fit the rules in the help center, please edit the question.


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 Aug 28 '16 at 8:36

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