I am trying to write an IF statement in CMD (.Bat file that will execute every hour) and I need to incorporate an IF statement to execute a move and SQL Statement if a file exists and to do nothing if it does not exist. When I run what I have it appears that it is ignoring the IF statement and runs everything. and skips the pause at the end. Am I missing something?
PAUSE
Set Year_Mo_Da=%date:~7,2%%date:~4,2%%date:~10,4%
time /t
pushd \\intranet.com\2014\%Year_Mo_Da%\FTP
    IF Exists *File_*.* (
    Copy *File_*.* Y:\Data\TEMP
    OSQL -E -S DC-Server -d Database -q "EXEC DBName.dbo.Notify_NoTouch 4"
    ) ELSE (
        Echo The file was not found.
        popd
    )
popd
time /t
PAUSE
Any help is appreciated. Thanks!
existinstead ofexists.