Your Task may for example only be able to work with JPG files but not TXT files. Put Filter.ByExtensions in front of it to make sure only the right files get through.
This works across sub-directories: Dropping a folder structure that contains JPG and TXT files in several levels will result in the same folder structure, but only with the JPG files.
Note: Filtering by file extension is not the same thing as filtering by extracted data type / UTI. Use the Task Filter.ByUTIs for this.
# extensions = ['txt', 'json', 'xml'] # default extensions = ['jpg']