BINGO!
Removed the echo and run the batch file. It calculate the first image but the rest of the file was an error. It says:
C:\path\to\bat\file>test.bat
C2011060.A1_ABC.ABCD.tif matches to 2011-03-01
Running calculation
0...10..Saving output
.20...30...40...50...60...70...80...90.
..100 - done.
Press any key to continue . . .
C:\path\to\bat\file>(
set "year=C2011061.A1_ABC.ABCD"
set "daynum=!year:~5,3!"
set "year=!year:~1,4!"
call :OrdinalToDate !year! !daynum! yy month dd
echo C2011061.A1_ABC.ABCD.tif matches to !yy!-!month!-!dd!
if !Month! == 01 set Month=jan
if !Month! == 02 set Month=feb
if !Month! == 03 set Month=mar
if !Month! == 04 set Month=apr
if !Month! == 05 set Month=may
if !Month! == 06 set Month=jun
if !Month! == 07 set Month=jul
if !Month! == 08 set Month=aug
if !Month! == 09 set Month=sep
if !Month! == 10 set Month=oct
if !Month! == 11 set Month=nov
if !Month! == 12 set Month=dec
gdal_calculate --out=%out_path%\C2011061.A1_ABC.ABCD.tif --calc="((image1-image2)" --image2=%sample_path%\sample_file_!Month!.tif --image1=%in_path%\C2011061.A1_ABC.ABCD.tif --extent=INTERSECT
pause
)
Invalid attempt to call batch label outside of batch script.
C2011061.A1_ABC.ABCD.tif matches to !yy!-!month!-!dd!
RuntimeError: `D:\Path\sample_file_!Month!.tif' does not exist in the file system
,
and is not recognised as a supported dataset name.
Press any key to continue . . .
C:\path\to\bat\file>(
set "year=C2011062.A1_ABC.ABCD"
set "daynum=!year:~5,3!"
set "year=!year:~1,4!"
call :OrdinalToDate !year! !daynum! yy month dd
echo C2011062.A1_ABC.ABCD.tif matches to !yy!-!month!-!dd!
if !Month! == 01 set Month=jan
if !Month! == 02 set Month=feb
if !Month! == 03 set Month=mar
if !Month! == 04 set Month=apr
if !Month! == 05 set Month=may
if !Month! == 06 set Month=jun
if !Month! == 07 set Month=jul
if !Month! == 08 set Month=aug
if !Month! == 09 set Month=sep
if !Month! == 10 set Month=oct
if !Month! == 11 set Month=nov
if !Month! == 12 set Month=dec
gdal_calculate --out=%out_path%\C2011062.A1_ABC.ABCD.tif --calc="((image1-image2)" --image2=%sample_path%\sample_file_!Month!.tif --image1=%in_path%\C2011062.A1_ABC.ABCD.tif --extent=INTERSECT
pause
)
Invalid attempt to call batch label outside of batch script.
C2011062.A1_ABC.ABCD.tif matches to !yy!-!month!-!dd!
RuntimeError: `D:\Path\sample_file_!Month!.tif' does not exist in the file system
,
and is not recognised as a supported dataset name.
Press any key to continue . . .