diff --git a/lib/setup/setupDestination b/lib/setup/setupDestination index 8c6b994..3239834 100644 --- a/lib/setup/setupDestination +++ b/lib/setup/setupDestination @@ -178,34 +178,159 @@ setupDestination() { Normalize (boolean): Normalize output files. EODesc + case ${destinationnormalize["$destination"]} in + 0) initialvalue=n ;; + 1) initialvalue=y ;; + *) unset initialvalue ;; + esac comeagain() { - : + read \ + -e \ + ${initialvalue+-i $initialvalue}\ + -p'Normalize (y/N): ' \ + value + case $value in + [yY]) + destinationnormalize["$destination"]=1 + ;; + ''|[nN]) + destinationnormalize["$destination"]=0 + ;; + *) + comeagain + ;; + esac } comeagain cat <<-EODesc + + Rename (string): + Destination files will be named according to , after + expansion of special strings: + %{album}, + %{albumartist}, + %{artist}, + %{disc}, + %{genre}, + %{title}, + %{track}, + %{year}. + Untagged files or files in unrecognized formats will not be changed. + + Leave blank if you don't want file renaming. EODesc + initialvalue="${destinationrenamepath["$destination"]}" + initialvalue+="${initialvalue+/}" + initialvalue+="${destinationrename["$destination"]}" + read \ + -e \ + ${initialvalue+-i"$initialvalue"} \ + -p'Rename pattern: ' \ + value + case "$value" in + */*) + destinationrenamepath["$destination"]="${value%/*}" + ;; + esac + destinationrename["$destination"]="${value##*/}" + cat <<-EODesc + + FAT32 Compatibility (boolean): + Rename files for compatibility with FAT32 filesystems. + EODesc + case ${destinationfat32compat["$destination"]} in + 0) initialvalue=n ;; + 1) initialvalue=y ;; + *) unset initialvalue ;; + esac comeagain() { - : + read \ + -e \ + ${initialvalue+-i $initialvalue}\ + -p'FAT32 Compatibility (y/N): ' \ + value + case $value in + [yY]) + destinationfat32compat["$destination"]=1 + ;; + ''|[nN]) + destinationfat32compat["$destination"]=0 + ;; + *) + comeagain + ;; + esac } comeagain cat <<-EODesc + + Skip mime-type (mime-type, string): + Files with mime-type will not be included in that + destination. The '*' character is a wildcard. + + This prompt will loop until an empty string is encountered. EODesc - comeagain() { - : - } - comeagain + destinationskipmime["$destination"]="${destinationskipmime["$destination"]}|" + while [[ ${destinationskipmime["$destination"]} =~ / ]] + do + skippedmimes+=("${destinationskipmime["$destination"]%%|*}") + destinationskipmime["$destination"]="${destinationskipmime["$destination"]#*|}" + done + count=${#skippedmimes[@]} + unset destinationskipmime["$destination"] + for (( i=0 ; 1 ; i++ )) + do + read \ + -e \ + ${skippedmimes[i]+-i"${skippedmimes[i]}"} \ + -p 'Skip mime-type: ' \ + value + if [ -n "$value" ] + then + destinationskipmime[$destination]="${destinationskipmime[$destination]:+${destinationskipmime[$destination]}|}$value" + elif (( i < count )) + then + continue + else + break + fi + done + unset skippedmimes cat <<-EODesc + + Copy mime-type (mime-type, string): + Files with mime-type will be copied as-is to the + destination. E.g. image/* will copy covers and other images to the + destination. The '*' character is a wildcard. + + This prompt will loop until an empty string is encountered. EODesc - comeagain() { - : - } - comeagain - cat <<-EODesc - EODesc - comeagain() { - : - } - comeagain + destinationcopymime["$destination"]="${destinationcopymime["$destination"]}|" + while [[ ${destinationcopymime["$destination"]} =~ / ]] + do + copiedmimes+=("${destinationcopymime["$destination"]%%|*}") + destinationcopymime["$destination"]="${destinationcopymime["$destination"]#*|}" + done + count=${#copiedmimes[@]} + unset destinationcopymime["$destination"] + for (( i=0 ; 1 ; i++ )) + do + read \ + -e \ + ${copiedmimes[i]+-i"${copiedmimes[i]}"} \ + -p 'Copy mime-type: ' \ + value + if [ -n "$value" ] + then + destinationcopymime[$destination]="${destinationcopymime[$destination]:+${destinationcopymime[$destination]}|}$value" + elif (( i < count )) + then + continue + else + break + fi + done + unset copiedmimes cat <<-EODesc EODesc comeagain() {