diff --git a/atom b/atom index 968a53f..40ee62a 100755 --- a/atom +++ b/atom @@ -14,6 +14,7 @@ EFMTINVPARM=49 # config structures declare -A \ destinationchannels \ + destinationfat32compat \ destinationcopymime \ destinationformat \ destinationfrequency \ @@ -255,7 +256,7 @@ getConfigDestination() { "'off'" ;; esac - ;; + ;; 'rename') case "$value" in */*) @@ -264,6 +265,21 @@ getConfigDestination() { esac destinationrename["$destination"]="${value##*/}" ;; + 'fat32compat') + case $value in + 'true'|'on'|'yes') + destinationfat32compat["$destination"]=1 + ;; + 'false'|'off'|'no') + destinationfat32compat["$destination"]=0 + ;; + *) + echo "fat32compat takes values:" \ + "'yes' ,'true' ,'on', 'no', 'false',"\ + "'off'" + ;; + esac + ;; 'skip_mime-type') destinationskipmime[$destination]="${destinationskipmime[$destination]:+${destinationskipmime[$destination]}|}$value" ;; @@ -759,7 +775,7 @@ gettag() { | sed -n "/^${1}=/I{s/^${1}=//I;p;q}" } -getInfosMP3_version='ID3-1' +getInfosMP3_version='ID3-2' tagreaders+=( "$getInfosMP3_version" ) getInfos::MP3() { tagreader="$getInfosMP3_version" @@ -773,12 +789,14 @@ getInfos::MP3() { title=$(gettag title) tracknum=$(gettag tracknumber) year=$(gettag year) - expr='^[0-9]*$' + expr='^\([0-9]*\)$' if [[ $genre =~ $expr ]] then + genre=${genre%)} + genre=${genre#(} genre="${id3genres[$genre]}" fi - infos="${infos//: /=}" + infos="${infos/: /=}" channels=$(gettag channels) rate=$(gettag 'sample rate') bitrate=$(gettag 'bit rate') @@ -809,7 +827,7 @@ getInfos::Ogg() { tracknum="$tracknum/$tracktotal" fi year=$(gettag date) - infos="${infos//: /=}" + infos="${infos/: /=}" rate=$(gettag rate|head -n1) channels=$(gettag channels|head -n1) bitrate=$(gettag 'nominal bitrate') @@ -1088,13 +1106,14 @@ copyFile() { " WHERE id=$destfileid" \ " )," \ " rename_pattern=" \ -"\"${destinationrenamepath[$destination]}/${destinationrename[$destination]}\""\ +"\"${destinationrenamepath[$destination]}/${destinationrename[$destination]}:${destinationfat32compat["$destination"]}\""\ "WHERE id=$destfileid;" \ >&3 (( ++copies )) } sanitizeFile() { + shopt -s extglob string="$1" # Filenames can't contain / string="${string//\// }" @@ -1112,8 +1131,7 @@ sanitizeFile() { # Filenames can't begin or end with ' ' string=${string/#+( )/} - string=${string//+( )./.} - string=${string//.+( )/.} + string=${string/%+( )/} fi echo "$string" } @@ -1139,7 +1157,13 @@ getDestDir() { replace=$(sanitizeFile "$disc") destdir="${destdir//%\{disc\}/$replace}" else - destdir+="${filename%/*}" + destdir+=$(sanitizeFile "${filename%%/*}") + part=${filename#*/} + while [[ $part =~ / ]] + do + destdir+="/$(sanitizeFile "${part%%/*}")" + part=${part#*/} + done fi if ! [ -d "$destdir" ] then @@ -1223,7 +1247,7 @@ encodeFile::mp3() { cleanup $tempdir/$tmpfile.wav source_file $fileid status 0 - rename_pattern "${destinationrenamepath[$destination]}/${destinationrename[$destination]}" + rename_pattern ${destinationrenamepath[$destination]}/${destinationrename[$destination]}:${destinationfat32compat["$destination"]} EOInsert ) progressSpin @@ -1297,338 +1321,306 @@ encodeFile::vorbis() { cleanup $tempdir/$tmpfile.wav source_file $fileid status 0 - rename_pattern "${destinationrenamepath[$destination]}/${destinationrename[$destination]}" + rename_pattern ${destinationrenamepath[$destination]}/${destinationrename[$destination]}:${destinationfat32compat["$destination"]} EOInsert ) progressSpin } worker() { - trap "kill -USR1 $masterpid" EXIT - while : - do - echo work - read line - until [[ $line != AtOM:ComFail ]] - do - echo work - read line - done - if [[ $line == AtOM:Die ]] - then - break - elif [[ $line == AtOM:Sleep ]] - then - sleep 1 - continue - fi - taskid=${line%%|*} - rest="${line#*|}|" - sourcefileid=${rest%%|*} - rest=${rest#*|} - required=${rest%%|*} - rest=${rest#*|} - cmd_arg=("${rest%%|*}") - rest=${rest#*|} - cmd_arg+=("${rest%%|*}") - rest=${rest#*|} - cmd_arg+=("${rest%%|*}") - rest=${rest#*|} - cmd_arg+=("${rest%%|*}") - rest=${rest#*|} - cmd_arg+=("${rest%%|*}") - rest=${rest#*|} - cmd_arg+=("${rest%%|*}") - rest=${rest#*|} - cmd_arg+=("${rest%%|*}") - rest=${rest#*|} - cmd_arg+=("${rest%%|*}") - rest=${rest#*|} - cmd_arg+=("${rest%%|*}") - rest=${rest#*|} - cmd_arg+=("${rest%%|*}") - rest=${rest#*|} - cmd_arg+=("${rest%%|*}") - rest=${rest#*|} - cmd_arg+=("${rest%%|*}") - rest=${rest#*|} - cmd_arg+=("${rest%%|*}") - rest=${rest#*|} - cmd_arg+=("${rest%%|*}") - rest=${rest#*|} - cmd_arg+=("${rest%%|*}") - rest=${rest#*|} - cmd_arg+=("${rest%%|*}") - rest=${rest#*|} - cmd_arg+=("${rest%%|*}") - rest=${rest#*|} - cmd_arg+=("${rest%%|*}") - rest=${rest#*|} - cmd_arg+=("${rest%%|*}") - rest=${rest#*|} - cmd_arg+=("${rest%%|*}") - rest=${rest#*|} - cmd_arg+=("${rest%%|*}") - rest=${rest#*|} - cmd_arg+=("${rest%%|*}") - rest=${rest#*|} - cmd_arg+=("${rest%%|*}") - rest=${rest#*|} - cmd_arg+=("${rest%%|*}") - rest=${rest#*|} - cmd_arg+=("${rest%%|*}") - rest=${rest#*|} - cmd_arg+=("${rest%%|*}") - rest=${rest#*|} - cmd_arg+=("${rest%%|*}") - rest=${rest#*|} - cmd_arg+=("${rest%%|*}") - rest=${rest#*|} - cmd_arg+=("${rest%%|*}") - rest=${rest#*|} - cmd_arg+=("${rest%%|*}") - rest=${rest#*|} - cleanup=${rest%%|*} - rest=${rest#*|} - destfileid=${rest%%|*} - rest=${rest#*|} - destfilename=${rest%%|*} - rest=${rest#*|} - for key in ${!cmd_arg[@]} - do - [ -z "${cmd_arg[key]}" ] && unset cmd_arg[key] - done - (( debug >= 2 )) && echo "${cmd_arg[@]}" >>"$tempdir/errors.log" - if "${cmd_arg[@]}" >/dev/null 2>>"$tempdir/errors.log" - then - echo "finished $taskid|$sourcefileid|$destfileid|$destfilename" - read line - until [[ $line == AtOM:OK ]] - do - echo "finished $taskid|$sourcefileid|$destfileid|$destfilename" - read line - done - else - echo "failed $taskid" - read line - until [[ $line == AtOM:OK ]] - do - echo "failed $taskid" - read line - done - [ -n "$filename" ] \ - && eval rm -f $filename - fi - unset cmd_arg - if [ -n "$cleanup" -a -n "$required" ] - then - echo "cleanup $required" - read answer - until [[ $answer != AtOM:ComFail ]] - do - echo "cleanup $required" - read answer - done - if (( answer == 1 )) - then - eval rm -f $cleanup - fi - fi - done - return + exec 2>>"$tempdir/worker$1.log" + (( debug >= 2 )) && echo "${cmd_arg[@]}" >&2 + "${cmd_arg[@]}" >/dev/null } master() { - for workerid in ${!workers[@]} - do - if read -t0.001 -u$((200+workerid)) workercommand workerquery + if (( active >= concurrency)) || [ -n "$quit" ] + then + sleep 0.1 + else + echo ' + SELECT COUNT(*) + FROM tasks + WHERE status = 0; + + SELECT COUNT(*) + FROM tasks + WHERE status = 0 + AND requires is NULL; + + SELECT + id, + source_file, + required, + cmd_arg0, + cmd_arg1, + cmd_arg2, + cmd_arg3, + cmd_arg4, + cmd_arg5, + cmd_arg6, + cmd_arg7, + cmd_arg8, + cmd_arg9, + cmd_arg10, + cmd_arg11, + cmd_arg12, + cmd_arg13, + cmd_arg14, + cmd_arg15, + cmd_arg16, + cmd_arg17, + cmd_arg18, + cmd_arg19, + cmd_arg20, + cmd_arg21, + cmd_arg22, + cmd_arg23, + cmd_arg24, + cmd_arg25, + cmd_arg26, + cmd_arg27, + cmd_arg28, + cmd_arg29, + cleanup, + fileid, + filename + FROM tasks + WHERE status = 0 + AND requires is NULL + ORDER BY source_file + LIMIT 1; + ' >&3 + read -u4 remaining + read -u4 ready + if (( remaining == 0 )) then - break + sleep 0.1 + continue + elif (( ready == 0 )) + then + sleep 0.1 + else + (( ++active )) + read -u4 line + taskid=${line%%|*} + rest="${line#*|}|" + sourcefileid=${rest%%|*} + rest=${rest#*|} + required=${rest%%|*} + rest=${rest#*|} + cmd_arg=("${rest%%|*}") + rest=${rest#*|} + cmd_arg+=("${rest%%|*}") + rest=${rest#*|} + cmd_arg+=("${rest%%|*}") + rest=${rest#*|} + cmd_arg+=("${rest%%|*}") + rest=${rest#*|} + cmd_arg+=("${rest%%|*}") + rest=${rest#*|} + cmd_arg+=("${rest%%|*}") + rest=${rest#*|} + cmd_arg+=("${rest%%|*}") + rest=${rest#*|} + cmd_arg+=("${rest%%|*}") + rest=${rest#*|} + cmd_arg+=("${rest%%|*}") + rest=${rest#*|} + cmd_arg+=("${rest%%|*}") + rest=${rest#*|} + cmd_arg+=("${rest%%|*}") + rest=${rest#*|} + cmd_arg+=("${rest%%|*}") + rest=${rest#*|} + cmd_arg+=("${rest%%|*}") + rest=${rest#*|} + cmd_arg+=("${rest%%|*}") + rest=${rest#*|} + cmd_arg+=("${rest%%|*}") + rest=${rest#*|} + cmd_arg+=("${rest%%|*}") + rest=${rest#*|} + cmd_arg+=("${rest%%|*}") + rest=${rest#*|} + cmd_arg+=("${rest%%|*}") + rest=${rest#*|} + cmd_arg+=("${rest%%|*}") + rest=${rest#*|} + cmd_arg+=("${rest%%|*}") + rest=${rest#*|} + cmd_arg+=("${rest%%|*}") + rest=${rest#*|} + cmd_arg+=("${rest%%|*}") + rest=${rest#*|} + cmd_arg+=("${rest%%|*}") + rest=${rest#*|} + cmd_arg+=("${rest%%|*}") + rest=${rest#*|} + cmd_arg+=("${rest%%|*}") + rest=${rest#*|} + cmd_arg+=("${rest%%|*}") + rest=${rest#*|} + cmd_arg+=("${rest%%|*}") + rest=${rest#*|} + cmd_arg+=("${rest%%|*}") + rest=${rest#*|} + cmd_arg+=("${rest%%|*}") + rest=${rest#*|} + cmd_arg+=("${rest%%|*}") + rest=${rest#*|} + cleanup=${rest%%|*} + rest=${rest#*|} + destfileid=${rest%%|*} + rest=${rest#*|} + destfilename=${rest%%|*} + rest=${rest#*|} + for key in ${!cmd_arg[@]} + do + [ -z "${cmd_arg[key]}" ] && unset cmd_arg[key] + done + workerid=$(getworkerid) + workertasks[workerid]=$taskid + Update tasks status 1 <<<"id = $taskid" + createworker $workerid + fi + fi +} + +getworkerid() { + local i + for (( i=0 ; i >= 0 ; i++ )) + do + if [ -z "${workers[i]}" ] + then + echo $i + return fi done - (( ${#workers[@]} == 0 )) && break - if [ -n "$workercommand" ] - then - case $workercommand in - 'work') - if [ -n "$quit" ] - then - dyingworker=${workers[workerid]} - unset workers[workerid] - eval echo AtOM:Die '>&'$((100+workerid)) - wait $dyingworker - eval $((100+workerid))'>&-' - eval $((200+workerid))'<&-' - rm "$tempdir"/worker${workerid}{in,out} - elif (( active < concurrency )) - then - echo ' - SELECT COUNT(*) - FROM tasks - WHERE status = 0; + # If we reach this, we have reached the signed long limit + # (2^63 - 1 = 9223372036854775807 - Got a supercomputer?) + (( concurrency-- )) +} - SELECT COUNT(*) - FROM tasks - WHERE status = 0 - AND requires is NULL; +createworker() { + worker $1 & + workers[$1]=$! +} - SELECT - id, - source_file, - required, - cmd_arg0, - cmd_arg1, - cmd_arg2, - cmd_arg3, - cmd_arg4, - cmd_arg5, - cmd_arg6, - cmd_arg7, - cmd_arg8, - cmd_arg9, - cmd_arg10, - cmd_arg11, - cmd_arg12, - cmd_arg13, - cmd_arg14, - cmd_arg15, - cmd_arg16, - cmd_arg17, - cmd_arg18, - cmd_arg19, - cmd_arg20, - cmd_arg21, - cmd_arg22, - cmd_arg23, - cmd_arg24, - cmd_arg25, - cmd_arg26, - cmd_arg27, - cmd_arg28, - cmd_arg29, - cleanup, - fileid, - filename - FROM tasks - WHERE status = 0 - AND requires is NULL - ORDER BY source_file - LIMIT 1; - ' >&3 - read -u4 remaining - read -u4 ready - if (( remaining == 0 )) - then - dyingworker=${workers[workerid]} - unset workers[workerid] - eval echo AtOM:Die '>&'$((100+workerid)) - wait $dyingworker - eval $((100+workerid))'>&-' - eval $((200+workerid))'<&-' - rm "$tempdir"/worker${workerid}{in,out} - continue - elif (( ready == 0 )) - then - line=AtOM:Sleep - else - (( ++active )) - read -u4 line - taskid=${line%%|*} - Update tasks status 1 <<<"id = $taskid" - fi - eval echo '"$line" >&'$((100+workerid)) - else - dyingworker=${workers[workerid]} - unset workers[workerid] - eval echo AtOM:Die '>&'$((100+workerid)) - wait $dyingworker - eval $((100+workerid))'>&-' - eval $((200+workerid))'<&-' - rm "$tempdir"/worker${workerid}{in,out} - fi - ;; - 'finished') - eval 'echo AtOM:OK >&'$((workerid+100)) - (( active-- )) || true - taskid=${workerquery%%|*} - rest="${workerquery#*|}|" - sourcefileid=${rest%%|*} - rest=${rest#*|} - destfileid=${rest%%|*} - rest=${rest#*|} - destfilename=${rest%%|*} - Delete tasks <<<"id = $taskid" - if [ -n "$destfilename" ] - then - echo \ - "UPDATE destination_files" \ - "SET filename=\"${destfilename//\"/\"\"}\"," \ - " last_change=(" \ - " SELECT last_change" \ - " FROM source_files" \ - " WHERE id=$sourcefileid" \ - " )," \ - " old_filename=(" \ - " SELECT filename" \ - " FROM destination_files" \ - " WHERE id=$destfileid" \ - " )," \ - " rename_pattern=(" \ - " SELECT rename_pattern" \ - " FROM tasks" \ - " WHERE id=$taskid" \ - " )" \ - "WHERE id=$destfileid;" \ - >&3 - fi - ;; - 'failed') - eval 'echo AtOM:OK >&'$((workerid+100)) - (( --active )) || true - (( ++failed )) - taskid=$workerquery - faildepends=$( - Select tasks 'COUNT(*)' <<-EOWhere - requires = taskid - EOWhere - ) - (( failed+=faildepends )) - Update tasks status 2 <<<"id = $taskid" - Update tasks status 2 <<<"requires = $taskid" - ;; - 'cleanup') - required=$workerquery - echo "SELECT COUNT(*) - FROM tasks - WHERE ( status = 0 OR status = 1 ) - AND required = $required;">&3 - read -u4 count - if (( count == 0 )) - then - eval echo 1 '>&'$((100+workerid)) - else - eval echo 0 '>&'$((100+workerid)) - fi - ;; - *) - eval 'echo "AtOM:ComFail" >&'$((100+workerid)) - ;; - esac - fi +destroyworker() { + dyingworker=${workers[$1]} + unset workers[$1] + wait $dyingworker +} + +gettaskinfos() { + echo ' + SELECT + id, + source_file, + required, + cleanup, + fileid, + filename + FROM tasks + WHERE id='$1'; + ' >&3 + read -u4 line + taskid=${line%%|*} + rest="${line#*|}|" + sourcefileid=${rest%%|*} + rest=${rest#*|} + required=${rest%%|*} + rest=${rest#*|} + cleanup=${rest%%|*} + rest=${rest#*|} + destfileid=${rest%%|*} + rest=${rest#*|} + destfilename=${rest%%|*} + rest=${rest#*|} +} + +cleaner() { + for key in ${!failedtasks[@]} + do + taskid=${failedtasks[key]} + gettaskinfos $taskid + faildepends=$( + Select tasks 'COUNT(*)' <<-EOWhere + requires = $taskid + EOWhere + ) + (( failed+=faildepends )) + Update tasks status 2 <<<"id = $taskid" + Update tasks status 2 <<<"requires = $taskid" + echo "SELECT COUNT(*) + FROM tasks + WHERE ( status = 0 OR status = 1 ) + AND required = $taskid;">&3 + read -u4 count + if (( count == 0 )) + then + rm -f "$cleanup" + fi + unset failedtasks[key] + done + for key in ${!finishedtasks[@]} + do + taskid=${finishedtasks[key]} + gettaskinfos $taskid + if [ -n "$destfilename" ] + then + echo \ + "UPDATE destination_files" \ + "SET filename=\"${destfilename//\"/\"\"}\"," \ + " last_change=(" \ + " SELECT last_change" \ + " FROM source_files" \ + " WHERE id=$sourcefileid" \ + " )," \ + " old_filename=(" \ + " SELECT filename" \ + " FROM destination_files" \ + " WHERE id=$destfileid" \ + " )," \ + " rename_pattern=(" \ + " SELECT rename_pattern" \ + " FROM tasks" \ + " WHERE id=$taskid" \ + " )" \ + "WHERE id=$destfileid;" \ + >&3 + fi + echo "SELECT COUNT(*) + FROM tasks + WHERE ( status = 0 OR status = 1 ) + AND required = $taskid;">&3 + read -u4 count + if (( count == 0 )) + then + rm -f "$cleanup" + fi + Delete tasks <<<"id = $taskid" + unset finishedtasks[key] + done } checkworkers() { for key in ${!workers[@]} do - if ! kill -0 ${workers[key]} + if ! kill -0 ${workers[key]} 2>/dev/null then - worker $key \ - <"$tempdir"/worker${key}in \ - >"$tempdir"/worker${key}out & - workers[key]=$! - eval exec $((100+key))'>"$tempdir"/worker${key}in' - eval exec $((200+key))'<"$tempdir"/worker${key}out' - (( ++failed )) + taskid=${workertasks[key]} + (( ++ran )) + (( active-- )) + if destroyworker $key + then + finishedtasks+=($taskid) + else + failedtasks+=($taskid) + (( ++failed )) + fi + unset workertasks[key] fi done } @@ -2075,28 +2067,21 @@ done echo 'COMMIT;' >&3 echo -e "\rCreated ${count:-0} tasks for $filecount files (${copies:-0} immediate copies)" -masterpid=$$ -trap checkworkers USR1 ALRM -rm -f "$tempdir"/worker* concurrency=$(( maxload / 2 )) (( concurrency )) || concurrency=1 active=0 +#set -x for (( i=0 ; i < concurrency ; i++ )) do - (( ++wnum )) - mkfifo "$tempdir"/worker${wnum}{in,out} - worker $wnum <"$tempdir"/worker${wnum}in >"$tempdir"/worker${wnum}out & - workers[wnum]=$! - eval exec $((100+wnum))'>"$tempdir"/worker${wnum}in' - eval exec $((200+wnum))'<"$tempdir"/worker${wnum}out' + master done concurrencychange=$(date +%s) starttime=$concurrencychange taskcount=$count failed=0 -while : +while (( ${#workers[@]} )) do - if read -n 1 -t 0.01 userinput + if read -n 1 -t 0.1 userinput then case $userinput in '+') @@ -2123,27 +2108,20 @@ do then concurrencychange=$(date +%s) (( ++concurrency )) - (( ++wnum )) - mkfifo "$tempdir"/worker${wnum}{in,out} - worker $wnum \ - <"$tempdir"/worker${wnum}in \ - >"$tempdir"/worker${wnum}out & - workers[wnum]=$! - eval exec $((100+wnum))'>"$tempdir"/worker${wnum}in' - eval exec $((200+wnum))'<"$tempdir"/worker${wnum}out' fi fi + checkworkers + cleaner master - if ((taskcount - remaining)) + if (( ran )) then currenttime=$(date +%s) - secsremaining=$(( - remaining - * - (currenttime - starttime) + avgduration=$(( + ((currenttime - starttime) * 1000) / - (taskcount - remaining) + ran )) + secsremaining=$(( remaining * avgduration / 1000 )) (( days = secsremaining / @@ -2159,12 +2137,28 @@ do / 60 )) || true + (( seconds = + secsremaining + - + ( ( ( ( days*24 + hours ) *60 ) + minutes ) *60 ) + )) || true + avgduration=$(printf %04i $avgduration) + avgdsec=${avgduration:0:-3} + avgdmsec=${avgduration#$avgdsec} fi - echo -en "\rload: $humanload / $maxload" \ - "workers: $active / $concurrency" \ - "done: $(( (taskcount - remaining ) * 100 / taskcount ))%" \ - "- $((taskcount - remaining)) of $taskcount ($failed failed)" \ - "${days}d ${hours}h${minutes}m " + dran=$(printf %${#taskcount}i ${ran:-0}) + rtime=$( + printf '%2id %2ih%02im%02is' \ + ${days:-0} \ + ${hours:-0} \ + ${minutes:-0} \ + ${seconds:-0} + ) + percent=$(printf %3i $((ran * 100 / taskcount))) + echo -en "\rL: $humanload/$maxload" \ + "W: $active/$concurrency" \ + "T: ${dran}/$taskcount (F:$failed) $percent% $rtime" \ + "(A: ${avgdsec:--}.${avgdmsec:--}s/task)" done unset count @@ -2192,7 +2186,7 @@ endtime=$(date +%s) ( ( ( ( days*24 + hours ) *60 ) + minutes ) *60 ) )) || true -echo -e "\rRan $taskcount tasks, $failed of which failed, in $days" \ +echo -e "\rRan ${ran:=0} tasks, $failed of which failed, in $days" \ "days, $hours hours, $minutes minutes and $seconds seconds." if [ -n "$quit" ] @@ -2207,6 +2201,8 @@ do echo ' SELECT destination_files.filename, + destination_files.id, + source_files.filename, tags.album, tags.albumartist, tags.artist, @@ -2224,11 +2220,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]}"'" +"'"${destinationrenamepath[$destination]}/${destinationrename[$destination]}:${destinationfat32compat["$destination"]}"'" OR destination_files.rename_pattern is NULL) + AND destination_files.last_change > 0 ; SELECT "AtOM:NoMoreFiles"; @@ -2246,6 +2246,10 @@ do do oldfilename=${line%%|*} rest=${line#*|}'|' + destfileid=${rest%%|*} + rest=${rest#*|} + filename=${rest%%|*} + rest=${rest#*|} album=${rest%%|*} rest=${rest#*|} albumartist=${rest%%|*} @@ -2271,16 +2275,21 @@ do getDestDir getDestFile destfilename="$destdir/$destfile.$extension" - mv "$oldfilename" "$destfilename" + if [[ $oldfilename != $destfilename ]] + then + mv "$oldfilename" "$destfilename" + progressSpin + fi echo "UPDATE destination_files" \ "SET filename=\"${destfilename//\"/\"\"}\"," \ " rename_pattern=" \ -"\"${destinationrenamepath[$destination]}/${destinationrename[$destination]}\"" \ +"\"${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 diff --git a/doc/config b/doc/config index a97a135..a32eead 100644 --- a/doc/config +++ b/doc/config @@ -66,6 +66,8 @@ Sections: %{track}, %{year}. Untagged files or files in unrecognized formats will not be changed. + * fat32compat /: Rename files for compatibility with FAT32 + filesystems. * skip_mime-type : Files with mime-type will not be included in that destination. For more than one mime-type, use multiple times, as needed. The '*' character is a wildcard.