0

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!

2
  • I think you want exist instead of exists. Commented Sep 9, 2014 at 16:13
  • AH! that is what spending most of your time in SQL will get you! thanks for that. Commented Sep 9, 2014 at 16:15

1 Answer 1

1

I'd try using if exist rather than if existS.

Using the correct keyword sometimes helps.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.