improved logic for parsing file name

added autoDownload switch