I am using Windows 5.1. Can someone please provide me with some assistance on the below batch file? This is what it should be doing;
This batch file first checks to see if files with the .dat extension exist in the temp directory. If there are no .dat files present in this directory it will move to the label call MESSAGE and display the words “No Files to Collect”‘. This part works fine.
If there are files in the temp directory, then it will move to the label call COPYFILE where it copy’s the files to the 997 directory, then checks within the 997 directory for files that starts with “A”. This part works fine.
If files starting with the “A” is present it is instructed to go to the label, REMOVEFILE. Within this label it will delete all the files beginning with “A”. This part works fine.
It then checks for the existence of other files in the 997 directory. If there are still files remaining after it has deleted all the ones starting with “A” then it will go to END. This part works fine.
If there are no files remaining in the 997 directory, then it should move to the label call MESSAGE and display the words, “No Files to Collect”. This part is where I am having problems. It does not work at all. It goes to END and do not display the message. It appears as if it does not see the MESSAGE label.
@echo off
if exist c:\temp\*.dat goto COPYFILE
if not exist c:\temp\*.dat goto MESSAGE
:COPYFILE
copy c:\temp\*.dat c:\temp\997\*.dat
if exist c:\temp\997\A*.dat goto REMOVEFILE
goto END
:REMOVEFILE
del c:\temp\997\A*.dat
if not exist c:\temp\997\*.* goto MESSAGE
if exist c:\temp\997\*.* goto END
:MESSAGE
echo “No Files To Collect”
goto END
:END