AtOM/lib/copy/matching
2026-01-16 03:45:34 +01:00

37 lines
1015 B
Bash

#!/bin/bash
copyFiles_matching() {
local extension="${filename##*.}"
if \
cp -al \
"$sourcepath/$filename" \
"${destinationpath[$destination]}/$destdir/$destfile.$extension" \
2>/dev/null \
|| cp -a \
"$sourcepath/$filename" \
"${destinationpath[$destination]}/$destdir/$destfile.$extension"
then
echo \
"UPDATE destination_files" \
"SET filename=" \
"\"${destdir//\"/\"\"}/${destfile//\"/\"\"}.$extension\"," \
" 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]}\","\
" fat32compat=" \
"${destinationfat32compat["$destination"]}," \
" ascii=${destinationascii["$destination"]}"\
"WHERE id=$destfileid;" \
>&3
(( ++copies ))
fi
}