scanFiles() js function