Fixed  filenameFromPattern so it replaces the ### characters with appropriate digits count