Assuming filenames is an array