AtOM/lib/files/getDestFile
2013-10-09 17:24:08 +02:00

60 lines
1.7 KiB
Bash

#!/bin/bash
getDestFile() {
if [ -n "${destinationrename[$destination]}" ] \
&& (
(
[[ ${destinationrename[$destination]} == \
*?([^[])%\{album\}?([^\]])* ]] \
&& [ -n "$album" ]
) || (
[[ ${destinationrename[$destination]} == \
*?([^[])%\{albumartist\}?([^\]])* ]] \
&& [ -n "$albumartist" ]
) || (
[[ ${destinationrename[$destination]} == \
*?([^[])%\{artist\}?([^\]])* ]] \
&& [ -n "$artist" ]
) || (
[[ ${destinationrename[$destination]} == \
*?([^[])%\{genre\}?([^\]])* ]] \
&& [ -n "$genre" ]
) || (
[[ ${destinationrename[$destination]} == \
*?([^[])%\{title\}?([^\]])* ]] \
&& [ -n "$title" ]
) || (
[[ ${destinationrename[$destination]} == \
*?([^[])%\{track\}?([^\]])* ]] \
&& [ -n "$track" ]
) || (
[[ ${destinationrename[$destination]} == \
*?([^[])%\{year\}?([^\]])* ]] \
&& [ -n "$year" ]
) || (
[[ ${destinationrename[$destination]} == \
*?([^[])%\{disc\}?([^\]])* ]] \
&& [ -n "$disc" ]
)
)
then
destfile="${destinationrename[$destination]//?(\[)%\{album\}?(\])/$album}"
destfile="${destfile//?(\[)%\{albumartist\}?(\])/$albumartist}"
destfile="${destfile//?(\[)%\{artist\}?(\])/$artist}"
destfile="${destfile//?(\[)%\{genre\}?(\])/$genre}"
destfile="${destfile//?(\[)%\{title\}?(\])/$title}"
tracknumber="${track%/*}"
destfile="${destfile//?(\[)%\{track\}?(\])/$tracknumber}"
destfile="${destfile//?(\[)%\{year\}?(\])/$year}"
destfile="${destfile//?(\[)%\{disc\}?(\])/$disc}"
else
destfile="${filename##*/}"
destfile="${destfile%.*}"
fi
if (( ${destinationascii["$destination"]} ))
then
echo "$destfile" >&${toascii[1]}
read -r -u${toascii[0]} destfile
fi
destfile=$(sanitizeFile "$destfile")
}