diff --git a/atom b/atom index 2427e57..c9d32e9 100755 --- a/atom +++ b/atom @@ -501,7 +501,7 @@ do getDestFile for copy_ext in "${destinationcopyext[@]}" do - if [[ $filename =~ '.*'"$copy_ext" ]] + if [[ $filename =~ '.*\.'"$copy_ext"'$' ]] then copied=1 break diff --git a/lib/config/getDestination b/lib/config/getDestination index 9792f8c..5284c75 100644 --- a/lib/config/getDestination +++ b/lib/config/getDestination @@ -186,7 +186,7 @@ getConfigDestination() { destinationcopymime[$destination]="${destinationcopymime[$destination]:+${destinationcopymime[$destination]}|}$value" ;; 'copy_extension') - destinationcopyext[$destination]="${destinationcopyext[$destination]:+${destinationcopyext[$destination]}|}\.$value$" + destinationcopyext[$destination]="${destinationcopyext[$destination]:+${destinationcopyext[$destination]}|}$value" ;; 'higher-than') expr='^[0-9]*$' diff --git a/lib/config/print b/lib/config/print index db25e0e..d684dcc 100644 --- a/lib/config/print +++ b/lib/config/print @@ -49,13 +49,13 @@ printConfig() { EOF [ -n "${destinationskipmime["$destination"]}" ] \ && echo " |Skipped mime-types|${destinationskipmime["$destination"]//\|/ -| | |}" +| |}" [ -n "${destinationcopymime["$destination"]}" ] \ && echo " |Copied mime-types|${destinationcopymime["$destination"]//\|/ -| | |}" +| |}" [ -n "${destinationcopyext["$destination"]}" ] \ && echo " |Copied extensions|${destinationcopyext["$destination"]//\|/ -| | |}" +| |}" done }|column -t -s'|' } diff --git a/lib/config/write b/lib/config/write index 4db01ed..f4954ad 100644 --- a/lib/config/write +++ b/lib/config/write @@ -208,8 +208,7 @@ bitrate ${destinationquality["$destination"]} done cat <<-EOCfg -# * copy_extension : Same as skip_extension, except that files -# matching will be copied as-is to the destination. +# * copy_extension : Copy files whose name and with "." EOCfg destinationcopyext["$destination"]="${destinationcopyext["$destination"]}|" while [[ ${destinationcopyext["$destination"]} =~ \| ]] diff --git a/lib/setup/destination b/lib/setup/destination index fcf214e..1885bfc 100644 --- a/lib/setup/destination +++ b/lib/setup/destination @@ -388,16 +388,16 @@ setupDestination() { copiedmimes+=("${destinationcopymime["$destination"]%%|*}") destinationcopymime["$destination"]="${destinationcopymime["$destination"]#*|}" done - [ -n "${destinationcopymime["$destination"]}" ] \ + [ -n "${destinationcopymime["$destination"]}" ] \ && copiedmimes+=("${destinationcopymime["$destination"]}") count=${#copiedmimes[@]} unset destinationcopymime["$destination"] for (( i=0 ; 1 ; i++ )) do - read \ - -e \ + read \ + -e \ ${copiedmimes[i]+-i"${copiedmimes[i]}"} \ - -p 'Copy mime-type: ' \ + -p 'Copy mime-type: ' \ value if [ -n "$value" ] then @@ -410,6 +410,44 @@ setupDestination() { fi done unset copiedmimes + + cat <<-EODesc + + Copy extensions (extension, string): + Files with extension will be copied as-is to the + destination. E.g. .jpg will copy covers and other images to the + destination. + + This prompt will loop until an empty string is encountered. + EODesc + while [[ ${destinationcopyext["$destination"]} =~ \| ]] + do + copiedexts+=("${destinationcopyext["$destination"]%%|*}") + destinationcopyext["$destination"]="${destinationcopyext["$destination"]#*|}" + done + [ -n "${destinationcopyext["$destination"]}" ] \ + && copiedexts+=("${destinationcopyext["$destination"]}") + count=${#copiedexts[@]} + unset destinationcopyext["$destination"] + for (( i=0 ; 1 ; i++ )) + do + read \ + -e \ + ${copiedexts[i]+-i"${copiedexts[i]}"} \ + -p 'Copy extension: ' \ + value + if [ -n "$value" ] + then + destinationcopyext[$destination]="${destinationcopyext[$destination]:+${destinationcopyext[$destination]}|}$value" + elif (( i < count )) + then + continue + else + break + fi + done + unset copiedexts + cat <<-EODesc Channels (integer): diff --git a/lib/setup/setup b/lib/setup/setup index a41601f..f6f9f8c 100644 --- a/lib/setup/setup +++ b/lib/setup/setup @@ -24,6 +24,7 @@ Completion is available for prompts asking for a paths or filenames. destinationchannels \ destinationfat32compat \ destinationcopymime \ + destinationcopyext \ destinationformat \ destinationfrequency \ destinationid \ @@ -40,6 +41,7 @@ Completion is available for prompts asking for a paths or filenames. destinationchannels \ destinationfat32compat \ destinationcopymime \ + destinationcopyext \ destinationformat \ destinationfrequency \ destinationid \ @@ -74,7 +76,7 @@ Completion is available for prompts asking for a paths or filenames. esac ;; esac - read -p'Run now? [Y/n] ' do_run + read -p'Run index and conversion now? [Y/n] ' do_run case $do_run in n) exit ;; *) ;;