Skip to main content
InSource Solutions

TN WW161 How to verify if a file exists using a batch file

InSource_Logo_Transparent.png

Description

 

This article from InSource shows how to verify if a file exists using a batch file

  • Author: Benjamin Davis
  • Published: 04/28/2016

Details

Use the Exist method to verify if a file exist using batch file scripting.

For example,

IF EXIST C:\Stuff\HelloWorld.txt (
        Del C:\Historian\HelloWorld.txt
    )

The script will look in the Stuff folder located on the C drive for a file called HelloWorld.txt.

If the file exist, it will delete the file. If it does not exist, nothing will occur.