Set mode based on file extensions.