replaces a pattern for all files in a directory