collect the filenames first