Quick glance gave me five IF EXIST in a row, then copying the files, definitely a logic error in the programming code. Haven't taken a closer look at the top part, too hard to read/decipher with a quick glance.

Maybe that code should be sent through the KiXStrip utility to find out what's wrong.
_________________________
There are two types of vessels, submarines and targets.