fix file rename

This commit is contained in:
Vincent Riquer 2013-04-04 23:34:48 +02:00
parent 11cd29d843
commit 98a2a13274

17
atom
View File

@ -2140,6 +2140,8 @@ do
echo '
SELECT
destination_files.filename,
destination_files.id,
source_files.filename,
tags.album,
tags.albumartist,
tags.artist,
@ -2157,11 +2159,15 @@ do
INNER JOIN tags
ON destination_files.source_file_id
=tags.source_file
INNER JOIN source_files
ON destination_files.source_file_id
=source_files.id
WHERE destinations.name="'"$destination"'"
AND (destination_files.rename_pattern
!=
"'"${destinationrenamepath[$destination]}/${destinationrename[$destination]}:${destinationfat32compat["$destination"]}"'"
OR destination_files.rename_pattern is NULL)
AND destination_files.last_change > 0
;
SELECT "AtOM:NoMoreFiles";
@ -2179,6 +2185,10 @@ do
do
oldfilename=${line%%|*}
rest=${line#*|}'|'
destfileid=${rest%%|*}
rest=${rest#*|}
filename=${rest%%|*}
rest=${rest#*|}
album=${rest%%|*}
rest=${rest#*|}
albumartist=${rest%%|*}
@ -2204,16 +2214,21 @@ do
getDestDir
getDestFile
destfilename="$destdir/$destfile.$extension"
if [[ $oldfilename != $destfilename ]]
then
mv "$oldfilename" "$destfilename"
progressSpin
fi
echo "UPDATE destination_files" \
"SET filename=\"${destfilename//\"/\"\"}\"," \
" rename_pattern=" \
"\"${destinationrenamepath[$destination]}/${destinationrename[$destination]}:${destinationfat32compat["$destination"]}\"" \
"WHERE id=$destfileid;" \
>&3
progressSpin
fi
read -u4 line
done
echo $'\r'"$destination: Renamed ${count:-0} files "
fi
unset count
done