I am writing a batch file that processes an image using an external toolkit based off an existing image (%%t
), querying a text file with columns of data for a specific value, and then feeding the queried data back into the batch process as new command criteria. My code is as follows:
for /r %%t in (*.tif) do (
cd /d C:\Program Files\Allegorithmic\Substance Automation Toolkit
sbsrender.exe render -v --input "C:\Program Files\Allegorithmic\Substance Automation Toolkit\test.sbsar" --set-entry input@"%%t" --output-path "C:\Users\Dave\Desktop\Substance" --output-format jpg --output-name "%%~nt"
cd C:\Users\Dave\Desktop\Substance
for /f "tokens=1-5 delims= " %%a in (C:\Users\Dave\Desktop\sectors.txt) do (
if "%%e"=="%%~nt" (
gdal_translate -of JPEG -co QUALITY=81 -a_ullr %%a %%b %%c %%d %%~nt.jpg %%~nt%-1.jpg
)
)
)
pause
An important aspect need to be in place - the name of the file generated in the first place has to be preserved as criteria for the query of the text file (%%~nt
), as it will be this value that specifies the coordinates to supply to the gdal_translate
command:
598000 5728000 602000 5724000 19
I am querying off this final value in the last column, because it should match the filename referenced in the very first line of code. The source tif
files correspond with rows in the text file. For this to work, "%%e"
should equal "%%~nt"
. It has to be returning the coordinates for the correct sector.
Thanks in advance.