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