Remove the quotes from:
set FileName="C:\Program Files\agent dir\agent.exe"
to be:
set FileName=C:\Program Files\agent dir\agent.exe
since we quote the variable in:
for %%A in ("%FileName%") do (
we don't need them in the set, and they will cause a problem.
Also, try adding the following ECHO in front of the IF statement, like:
ECHO B=[%%B], MatchDate=[%MatchDate%]
if "%%B"=="%MatchDate%" exit /b
so we can see what the dates are it's comparing
~bp