Question : IF - Then script based on file date?

Hi All, sorry if this is simple, but my searches have not turned up a solution.  I simply need to create a batch file (startup script) to check a certain file's date and if that file matches the specified date, do not run the script and instead goto :end, but if the file does "not" match the specified date, then goto :script.  Is there an easy way to achieve this?


Answer : IF - Then script based on file date?

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

Random Solutions  
programming4us programming4us