0

I need to write a batch script to run on windows.

I will schedule that file to run every minute on the server to test the existence of a txt file, on that server and then delete it.

Wha the batch file does is this:

check the existence of txt file on the server and if it finds that file in that location, 1) delete it 2 ) run some other actions.

I know what those actions are. I got the code for it already.

I need help only on how to check the existence of that txt file and how to delete it if it is there.

What commands do I need?

I'd appreciate if you could throw some pointers.

Average Joe
  • 4,521
  • 9
  • 53
  • 81
  • Possible duplicate of [How to check if a file exists from inside a batch file](http://stackoverflow.com/questions/4340350/how-to-check-if-a-file-exists-from-inside-a-batch-file) – Thomas Dickey Jul 30 '16 at 13:34
  • 3
    Possible duplicate of [How to verify if a file exists in a Windows .BAT file?](http://stackoverflow.com/questions/3022176/how-to-verify-if-a-file-exists-in-a-windows-bat-file) – IInspectable Jul 30 '16 at 13:57

1 Answers1

0

Rob Van Der Woude's batch file reference is an excellent source: http://www.robvanderwoude.com/if.php As it examples show how this can be achieved.

IF [NOT] EXIST filename command

Something like this...

IF EXIST file.txt Start script.bat

Or...

IF EXIST file.txt GOTO somelabel
Joe DF
  • 5,438
  • 6
  • 41
  • 63