Factor filename writing out of batch window