Batch script for creating tileindices
Scenario
You have multiple Base Maps (such as historic maps of different years or scales) inside a root folder such as E:\iShareData\Maps\Historic.
The folder structure might be something like:
- E:\iShareData\Maps\Historic\OS First Edition 10000\[tifs with tfw files]
- E:\iShareData\Maps\Historic\OS Second Edition 10000\[tifs with tfw files]
- E:\iShareData\Maps\Historic\OS Third Edition 10000\[tifs with tfw files]
- E:\iShareData\Maps\Historic\OS First Edition 2500\[tifs with tfw files]
- E:\iShareData\Maps\Historic\OS Second Edition 2500\[tifs with tfw files]
- E:\iShareData\Maps\Historic\OS Third Edition 2500\[tifs with tfw files]
Instructions
Save the following as a batch file and place it in the "Historic" folder, as per the above structure.Â
Important
Make sure that you have the correct path to gdaltindex.exe and the correct extensions/formats for your image files. Adjust as appropriate.
REM iterate through each folder and sub folder in your root directory FOR /D /r %%G in ("\*") DO ( REM create a txt file named with just the folder name, not the whole path, with the full paths to all the image files in the folder dir /s/b %%G | find "tif" > "%%~nxG-index.txt" REM run gdaltindex.exe to create a shape file in the root folder, with the name of the sub-folder, using the txt file above as the optfile D:\Astun\Tools\OGR\gdaltindex.exe "%%G.shp" --optfile "%%~nxG-index.txt" )
You can then use these shape files as the basis for your raster layers, following the configuration instructions in Configuring Raster Layers.