What do you mean by batch script? Is it running in side or outside Drupal? Is it possible it's a permission problem or that you are running out of memory?