handle rename pattern change
This commit is contained in:
parent
722a3896b4
commit
49031cde33
115
atom
115
atom
@ -1059,7 +1059,14 @@ copyFile() {
|
|||||||
" SELECT last_change" \
|
" SELECT last_change" \
|
||||||
" FROM source_files" \
|
" FROM source_files" \
|
||||||
" WHERE id=$fileid" \
|
" WHERE id=$fileid" \
|
||||||
" )" \
|
" )," \
|
||||||
|
" old_filename=(" \
|
||||||
|
" SELECT filename" \
|
||||||
|
" FROM destination_files" \
|
||||||
|
" WHERE id=$destfileid" \
|
||||||
|
" )," \
|
||||||
|
" rename_pattern=" \
|
||||||
|
"\"${destinationrenamepath[$destination]}/${destinationrename[$destination]}\""\
|
||||||
"WHERE id=$destfileid;" \
|
"WHERE id=$destfileid;" \
|
||||||
>&3
|
>&3
|
||||||
(( ++copies ))
|
(( ++copies ))
|
||||||
@ -1194,6 +1201,7 @@ encodeFile::mp3() {
|
|||||||
cleanup $tempdir/$tmpfile.wav
|
cleanup $tempdir/$tmpfile.wav
|
||||||
source_file $fileid
|
source_file $fileid
|
||||||
status 0
|
status 0
|
||||||
|
rename_pattern "${destinationrenamepath[$destination]}/${destinationrename[$destination]}"
|
||||||
EOInsert
|
EOInsert
|
||||||
)
|
)
|
||||||
progressSpin
|
progressSpin
|
||||||
@ -1228,6 +1236,7 @@ encodeFile::vorbis() {
|
|||||||
cleanup $tempdir/$tmpfile.wav
|
cleanup $tempdir/$tmpfile.wav
|
||||||
source_file $fileid
|
source_file $fileid
|
||||||
status 0
|
status 0
|
||||||
|
rename_pattern "${destinationrenamepath[$destination]}/${destinationrename[$destination]}"
|
||||||
EOInsert
|
EOInsert
|
||||||
)
|
)
|
||||||
progressSpin
|
progressSpin
|
||||||
@ -1502,6 +1511,11 @@ master() {
|
|||||||
" SELECT filename" \
|
" SELECT filename" \
|
||||||
" FROM destination_files" \
|
" FROM destination_files" \
|
||||||
" WHERE id=$destfileid" \
|
" WHERE id=$destfileid" \
|
||||||
|
" )," \
|
||||||
|
" rename_pattern=(" \
|
||||||
|
" SELECT rename_pattern" \
|
||||||
|
" FROM tasks" \
|
||||||
|
" WHERE id=$taskid" \
|
||||||
" )" \
|
" )" \
|
||||||
"WHERE id=$destfileid;" \
|
"WHERE id=$destfileid;" \
|
||||||
>&3
|
>&3
|
||||||
@ -1767,6 +1781,7 @@ echo '
|
|||||||
CREATE TEMPORARY TABLE tasks(
|
CREATE TEMPORARY TABLE tasks(
|
||||||
id INTEGER PRIMARY KEY,
|
id INTEGER PRIMARY KEY,
|
||||||
key TEXT UNIQUE,
|
key TEXT UNIQUE,
|
||||||
|
rename_pattern TEXT,
|
||||||
source_file INTEGER,
|
source_file INTEGER,
|
||||||
fileid INTEGER,
|
fileid INTEGER,
|
||||||
filename TEXT,
|
filename TEXT,
|
||||||
@ -2096,22 +2111,22 @@ endtime=$(date +%s)
|
|||||||
|
|
||||||
(( elapsedseconds = endtime - starttime ))
|
(( elapsedseconds = endtime - starttime ))
|
||||||
(( days =
|
(( days =
|
||||||
secsremaining
|
elapsedseconds
|
||||||
/
|
/
|
||||||
( 24*60*60 )
|
( 24*60*60 )
|
||||||
)) || true
|
)) || true
|
||||||
(( hours =
|
(( hours =
|
||||||
( secsremaining - ( days*24*60*60 ) )
|
( elapsedseconds - ( days*24*60*60 ) )
|
||||||
/
|
/
|
||||||
( 60*60 )
|
( 60*60 )
|
||||||
)) || true
|
)) || true
|
||||||
(( minutes =
|
(( minutes =
|
||||||
( secsremaining - ( ( days*24 + hours ) *60*60 ) )
|
( elapsedseconds - ( ( days*24 + hours ) *60*60 ) )
|
||||||
/
|
/
|
||||||
60
|
60
|
||||||
)) || true
|
)) || true
|
||||||
(( seconds =
|
(( seconds =
|
||||||
secsremaining
|
elapsedseconds
|
||||||
-
|
-
|
||||||
( ( ( ( days*24 + hours ) *60 ) + minutes ) *60 )
|
( ( ( ( days*24 + hours ) *60 ) + minutes ) *60 )
|
||||||
)) || true
|
)) || true
|
||||||
@ -2119,6 +2134,96 @@ endtime=$(date +%s)
|
|||||||
echo -e "\rRan $taskcount tasks, $failed of which failed, in $days" \
|
echo -e "\rRan $taskcount tasks, $failed of which failed, in $days" \
|
||||||
"days, $hours hours, $minutes minutes and $seconds seconds."
|
"days, $hours hours, $minutes minutes and $seconds seconds."
|
||||||
|
|
||||||
|
if [ -n "$quit" ]
|
||||||
|
then
|
||||||
|
closeDatabase
|
||||||
|
exit
|
||||||
|
fi
|
||||||
|
|
||||||
|
#set -x
|
||||||
|
for destination in "${!destinationpath[@]}"
|
||||||
|
do
|
||||||
|
echo '
|
||||||
|
SELECT
|
||||||
|
destination_files.filename,
|
||||||
|
tags.album,
|
||||||
|
tags.albumartist,
|
||||||
|
tags.artist,
|
||||||
|
tags.composer,
|
||||||
|
tags.disc,
|
||||||
|
tags.genre,
|
||||||
|
tags.performer,
|
||||||
|
tags.title,
|
||||||
|
tags.track,
|
||||||
|
tags.year
|
||||||
|
FROM destination_files
|
||||||
|
INNER JOIN destinations
|
||||||
|
ON destination_files.destination_id
|
||||||
|
=destinations.id
|
||||||
|
INNER JOIN tags
|
||||||
|
ON destination_files.source_file_id
|
||||||
|
=tags.source_file
|
||||||
|
WHERE destinations.name="'"$destination"'"
|
||||||
|
AND (destination_files.rename_pattern
|
||||||
|
!=
|
||||||
|
"'"${destinationrenamepath[$destination]}/${destinationrename[$destination]}"'"
|
||||||
|
OR destination_files.rename_pattern is NULL)
|
||||||
|
;
|
||||||
|
|
||||||
|
SELECT "AtOM:NoMoreFiles";
|
||||||
|
' >&3
|
||||||
|
|
||||||
|
read -u4 line
|
||||||
|
if [[ $line != AtOM:NoMoreFiles ]]
|
||||||
|
then
|
||||||
|
case "${destinationformat[$destination]}" in
|
||||||
|
'mp3') extension=mp3 ;;
|
||||||
|
'vorbis') extension=ogg ;;
|
||||||
|
esac
|
||||||
|
echo -n "$destination: rename pattern changed, renaming files... "
|
||||||
|
while [[ $line != AtOM:NoMoreFiles ]]
|
||||||
|
do
|
||||||
|
oldfilename=${line%%|*}
|
||||||
|
rest=${line#*|}'|'
|
||||||
|
album=${rest%%|*}
|
||||||
|
rest=${rest#*|}
|
||||||
|
albumartist=${rest%%|*}
|
||||||
|
rest=${rest#*|}
|
||||||
|
artist=${rest%%|*}
|
||||||
|
rest=${rest#*|}
|
||||||
|
composer=${rest%%|*}
|
||||||
|
rest=${rest#*|}
|
||||||
|
disc=${rest%%|*}
|
||||||
|
rest=${rest#*|}
|
||||||
|
genre=${rest%%|*}
|
||||||
|
rest=${rest#*|}
|
||||||
|
performer=${rest%%|*}
|
||||||
|
rest=${rest#*|}
|
||||||
|
title=${rest%%|*}
|
||||||
|
rest=${rest#*|}
|
||||||
|
track=${rest%%|*}
|
||||||
|
rest=${rest#*|}
|
||||||
|
year=${rest%%|*}
|
||||||
|
rest=${rest#*|}
|
||||||
|
if [ -n "$oldfilename" -a -f "$oldfilename" ]
|
||||||
|
then
|
||||||
|
getDestDir
|
||||||
|
getDestFile
|
||||||
|
destfilename="$destdir/$destfile.$extension"
|
||||||
|
mv "$oldfilename" "$destfilename"
|
||||||
|
echo "UPDATE destination_files" \
|
||||||
|
"SET filename=\"${destfilename//\"/\"\"}\"," \
|
||||||
|
" rename_pattern=" \
|
||||||
|
"\"${destinationrenamepath[$destination]}/${destinationrename[$destination]}\"" \
|
||||||
|
"WHERE id=$destfileid;" \
|
||||||
|
>&3
|
||||||
|
progressSpin
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
unset count
|
||||||
|
done
|
||||||
|
|
||||||
echo '
|
echo '
|
||||||
SELECT id,
|
SELECT id,
|
||||||
old_filename
|
old_filename
|
||||||
|
|||||||
@ -18,6 +18,7 @@ CREATE TABLE destination_files (
|
|||||||
id INTEGER PRIMARY KEY,
|
id INTEGER PRIMARY KEY,
|
||||||
filename TEXT,
|
filename TEXT,
|
||||||
old_filename TEXT,
|
old_filename TEXT,
|
||||||
|
rename_pattern TEXT,
|
||||||
last_change FLOAT NOT NULL DEFAULT 0,
|
last_change FLOAT NOT NULL DEFAULT 0,
|
||||||
source_file_id INTEGER,
|
source_file_id INTEGER,
|
||||||
destination_id INTEGER,
|
destination_id INTEGER,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user