function find_sidecar () { file_a="$1" search_path="$2" # check if file_a is aae file or heic file if [[ $file_a == *.aae ]]; then # we need to find a .heic file find "$search_path" -type f -iname "${file_a:r}.heic" else # we need to find a .aae file find "$search_path" -type f -iname "${file_a:r}.aae" fi }