Windows batch file question

Hi, just looking for help from anyone familiar with Windows batch files, I’ve got the following code which is partially working but can’t figure out why the second FOR loop is failing to run. Have I made a mistake with the syntax? If I cut the first FOR loop out the second one runs but with the first loop in there the second one won’t run. Any help appreciated.

@ECHO ON
echo RMSE 0.06
SET rmse=0.06
SET /P input=Enter folder to process:
echo %input%>Similar_images2.txt
md %input%\mapillary_sampled_video_frames\Similar2
@ECHO OFF
SETLOCAL ENABLEDELAYEDEXPANSION

for /d %%z in (%input%\mapillary_sampled_video_frames*) do (cd %input%\mapillary_sampled_video_frames
if %%~nxz NEQ Similar (
TIMEOUT /T 1
if %%~nxz NEQ Similar2 (
powershell write-host -fore Yellow Folder = %%~nz
move /-y “%cd%%input%\mapillary_sampled_video_frames%%~nz” “%cd%%input%\mapillary_sampled_video_frames\Similar_checked%%~nz”
)
)
)

PAUSE

for /d %%G in (%input%\mapillary_sampled_video_frames\Similar_checked*) do (cd %input%\mapillary_sampled_video_frames\Similar_checked
if %%~nxG NEQ Similar (
TIMEOUT /T 1
if %%~nxG NEQ Similar2 (
powershell write-host -fore Yellow Folder = %%~nG
move /-y “%cd%%input%\mapillary_sampled_video_frames\Similar_checked%%~nG” “%cd%%input%\mapillary_sampled_video_frames%%~nG”
)
)
)

PAUSE