Explain how you would optimize a slow-running Bash script that processes thousands of laboratory files sequentially.