You have a few problems.
Your definition of MYPATH is wrong. Spaces are significant when doing SET assignments. You created a variable name with a space at the end and a value with a space in the front.
FOR variable names are case sensitive:
%%i
and%%I
are not the same thingSET outfile=%MYPATHFILE%.shp!
would have to change toSET outfile=!MYPATHFILE!.shp
But your script can be simplified tremendously:
for %%F in ("C:\Users\mkcarte2\Desktop\Polygonize\*.tif") do ( gdal_polygonize "%%F" "ESRI Shapefile" "%%~dpnF.shp" )
Or you could run a simple one liner from the command line, without any script:
for %F in ("C:\Users\mkcarte2\Desktop\Polygonize\*.tif") do gdal_polygonize "%F" "ESRI Shapefile" "%~dpnF.shp"