[gdal-dev] Gdal_translate batch processing

Matt.Wilkie at yukon.ca Matt.Wilkie at yukon.ca
Tue May 4 10:33:51 PDT 2021

Hi Gulnihal,

Something like this should work:

    pushd C:\Users\HP\Desktop\modis
    for /r %F in (*.hdf) do @echo gdal_translate -sds %F %~dpnF.tif

This is a dry run to show what it will attempt, it won't actually do anything. Remove the "@echo" part to make it active. Double the % to use in a batch file (so "for /r %%F ...").

For help on what is being done here see:

 * https://ss64.com/nt/for_r.html
 * https://ss64.com/nt/syntax-args.html - what the "%~dpnF" part is doing.
 * https://ss64.com/nt/syntax-percent.html



-----Original Message-----
From: gdal-dev <gdal-dev-bounces at lists.osgeo.org> On Behalf Of gnihalk
Sent: April 29, 2021 5:36 AM
To: gdal-dev at lists.osgeo.org
Subject: [gdal-dev] Gdal_translate batch processing

<strong>*** External email: Do not click on links or attachments except from trusted senders. *** ******************************************************************************************</strong>
Hi you all. I have a huge MODIS dataset and I need to translate them to tiff but each data is in a different sub-folder.
the dataset sub-folders go like this...

and the code that im trying to run is:
for /R C:\Users\HP\Desktop\modis\5000000889913\5000000889913\88258783 %f IN
(MOD10A2.2016322095024.hdf) do gdal_translate.exe -sds -of gtiff %f C:\Users\HP\Desktop\modis\5000000889913\5000000889913\88258783\MOD10A2.2016322095024.tiff

I tried to make a loop for all subfolders that I have but I got an error massage. I would appreciate it if I can take your opinions about it. I am also not sure that I post this question in true title/section.
Thank you,

Sent from: http://osgeo-org.1560.x6.nabble.com/GDAL-Dev-f3742093.html
gdal-dev mailing list
gdal-dev at lists.osgeo.org

More information about the gdal-dev mailing list