Resolve "BUG: Setup is not aware of copy_extension"

This commit is contained in:
ScriptFanix 2025-04-15 21:36:31 +00:00
parent 29e8616ff9
commit 95ce31a54a
6 changed files with 51 additions and 12 deletions

2
atom
View File

@ -501,7 +501,7 @@ do
getDestFile getDestFile
for copy_ext in "${destinationcopyext[@]}" for copy_ext in "${destinationcopyext[@]}"
do do
if [[ $filename =~ '.*'"$copy_ext" ]] if [[ $filename =~ '.*\.'"$copy_ext"'$' ]]
then then
copied=1 copied=1
break break

View File

@ -186,7 +186,7 @@ getConfigDestination() {
destinationcopymime[$destination]="${destinationcopymime[$destination]:+${destinationcopymime[$destination]}|}$value" destinationcopymime[$destination]="${destinationcopymime[$destination]:+${destinationcopymime[$destination]}|}$value"
;; ;;
'copy_extension') 'copy_extension')
destinationcopyext[$destination]="${destinationcopyext[$destination]:+${destinationcopyext[$destination]}|}\.$value$" destinationcopyext[$destination]="${destinationcopyext[$destination]:+${destinationcopyext[$destination]}|}$value"
;; ;;
'higher-than') 'higher-than')
expr='^[0-9]*$' expr='^[0-9]*$'

View File

@ -49,13 +49,13 @@ printConfig() {
EOF EOF
[ -n "${destinationskipmime["$destination"]}" ] \ [ -n "${destinationskipmime["$destination"]}" ] \
&& echo " |Skipped mime-types|${destinationskipmime["$destination"]//\|/ && echo " |Skipped mime-types|${destinationskipmime["$destination"]//\|/
| | |}" | |}"
[ -n "${destinationcopymime["$destination"]}" ] \ [ -n "${destinationcopymime["$destination"]}" ] \
&& echo " |Copied mime-types|${destinationcopymime["$destination"]//\|/ && echo " |Copied mime-types|${destinationcopymime["$destination"]//\|/
| | |}" | |}"
[ -n "${destinationcopyext["$destination"]}" ] \ [ -n "${destinationcopyext["$destination"]}" ] \
&& echo " |Copied extensions|${destinationcopyext["$destination"]//\|/ && echo " |Copied extensions|${destinationcopyext["$destination"]//\|/
| | |}" | |}"
done done
}|column -t -s'|' }|column -t -s'|'
} }

View File

@ -208,8 +208,7 @@ bitrate ${destinationquality["$destination"]}
done done
cat <<-EOCfg cat <<-EOCfg
# * copy_extension <extension>: Same as skip_extension, except that files # * copy_extension <extension>: Copy files whose name and with ".<extension>"
# matching will be copied as-is to the destination.
EOCfg EOCfg
destinationcopyext["$destination"]="${destinationcopyext["$destination"]}|" destinationcopyext["$destination"]="${destinationcopyext["$destination"]}|"
while [[ ${destinationcopyext["$destination"]} =~ \| ]] while [[ ${destinationcopyext["$destination"]} =~ \| ]]

View File

@ -388,16 +388,16 @@ setupDestination() {
copiedmimes+=("${destinationcopymime["$destination"]%%|*}") copiedmimes+=("${destinationcopymime["$destination"]%%|*}")
destinationcopymime["$destination"]="${destinationcopymime["$destination"]#*|}" destinationcopymime["$destination"]="${destinationcopymime["$destination"]#*|}"
done done
[ -n "${destinationcopymime["$destination"]}" ] \ [ -n "${destinationcopymime["$destination"]}" ] \
&& copiedmimes+=("${destinationcopymime["$destination"]}") && copiedmimes+=("${destinationcopymime["$destination"]}")
count=${#copiedmimes[@]} count=${#copiedmimes[@]}
unset destinationcopymime["$destination"] unset destinationcopymime["$destination"]
for (( i=0 ; 1 ; i++ )) for (( i=0 ; 1 ; i++ ))
do do
read \ read \
-e \ -e \
${copiedmimes[i]+-i"${copiedmimes[i]}"} \ ${copiedmimes[i]+-i"${copiedmimes[i]}"} \
-p 'Copy mime-type: ' \ -p 'Copy mime-type: ' \
value value
if [ -n "$value" ] if [ -n "$value" ]
then then
@ -410,6 +410,44 @@ setupDestination() {
fi fi
done done
unset copiedmimes unset copiedmimes
cat <<-EODesc
Copy extensions (extension, string):
Files with extension <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 cat <<-EODesc
Channels (integer): Channels (integer):

View File

@ -24,6 +24,7 @@ Completion is available for prompts asking for a paths or filenames.
destinationchannels \ destinationchannels \
destinationfat32compat \ destinationfat32compat \
destinationcopymime \ destinationcopymime \
destinationcopyext \
destinationformat \ destinationformat \
destinationfrequency \ destinationfrequency \
destinationid \ destinationid \
@ -40,6 +41,7 @@ Completion is available for prompts asking for a paths or filenames.
destinationchannels \ destinationchannels \
destinationfat32compat \ destinationfat32compat \
destinationcopymime \ destinationcopymime \
destinationcopyext \
destinationformat \ destinationformat \
destinationfrequency \ destinationfrequency \
destinationid \ destinationid \
@ -74,7 +76,7 @@ Completion is available for prompts asking for a paths or filenames.
esac esac
;; ;;
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 case $do_run in
n) exit ;; n) exit ;;
*) ;; *) ;;