#!/bin/bash copyFiles_matching() { extension="${filename##*.}" cp -al \ "$sourcepath/$filename" \ "$destdir/$destfile.$extension" \ 2>/dev/null \ || cp -a \ "$sourcepath/$filename" \ "$destdir/$destfile.$extension" echo \ "UPDATE destination_files" \ "SET filename=\"${filename//\"/\"\"}\"," \ " last_change=(" \ " SELECT last_change" \ " FROM source_files" \ " WHERE id=$fileid" \ " )," \ " old_filename=(" \ " SELECT filename" \ " FROM destination_files" \ " WHERE id=$destfileid" \ " )," \ " rename_pattern=" \ "\"${destinationrenamepath[$destination]}/${destinationrename[$destination]}:${destinationfat32compat["$destination"]}\""\ "WHERE id=$destfileid;" \ >&3 (( ++copies )) }