AtOM/lib/files/getDestFile
2013-10-09 17:20:36 +02:00

54 lines
1.6 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" ]
)
)
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
destfile=$(sanitizeFile "$destfile")
}