Check for presence of batch file with IF EXIST

You can check whether certain files are present using an 'IF EXIST' command. You can use this to execute commands via a batch file.

Configure batch file:

  • When performing one task, the syntax is:

    IF EXIST batchfile.bat command

  • When performing several commands. You can insert a jump to clarify:

    IF NOT EXIST batchfile.bat GOTO DOESNOTEXIST

    'enter your command lines here'

    :DOESNOTEXIST

    'continue here'

  • If you want to perform one action if the file exists and another action if the file does not exist, you can do this as follows:

    IF EXIST batchfile.bat GOTO EXISTS

    'enter the lines used if the file does not exist here'

    GOTO FURTHER EXISTS

    'enter the lines used if the file exists here'

    FURTHER

  • If any spaces are present in the path name, you must place the entire path+filename+extension between straight double quotes.

    IF EXIST "C:\Program FIles (x86)\batchfile.bat" GOTO BESTAAT

Directly to

  1. Configuration of scheduled tasks
  2. Schedule regular tasks
  3. Scheduled tasks with more than one schedule
  4. Check for presence of batch file with IF EXIST
  5. Command line for general logging via batch file