#!/bin/bash getDestDir() { destdir="${destinationpath[$destination]}/" if [ -n "${destinationrenamepath[$destination]}" ] \ && ( ( ! [[ ${destinationrenamepath[$destination]} =~ %{album} ]] \ || [ -n "$album" ] ) && ( ! [[ ${destinationrenamepath[$destination]} =~ %{albumartist} ]] \ || [ -n "$albumartist" ] ) && ( ! [[ ${destinationrenamepath[$destination]} =~ %{artist} ]] \ || [ -n "$artist" ] ) && ( ! [[ ${destinationrenamepath[$destination]} =~ %{genre} ]] \ || [ -n "$genre" ] ) && ( ! [[ ${destinationrenamepath[$destination]} =~ %{title} ]] \ || [ -n "$title" ] ) && ( ! [[ ${destinationrenamepath[$destination]} =~ %{track} ]] \ || [ -n "$track" ] ) && ( ! [[ ${destinationrenamepath[$destination]} =~ %{year} ]] \ || [ -n "$year" ] ) && ( ! [[ ${destinationrenamepath[$destination]} =~ %{disc} ]] \ || [ -n "$disc" ] ) ) then replace=$(sanitizeFile "$album" dir) destdir+="${destinationrenamepath[$destination]//%\{album\}/$replace}" replace=$(sanitizeFile "$albumartist" dir) destdir="${destdir//%\{albumartist\}/$replace}" replace=$(sanitizeFile "$artist" dir) destdir="${destdir//%\{artist\}/$replace}" replace=$(sanitizeFile "$genre" dir) destdir="${destdir//%\{genre\}/$replace}" replace=$(sanitizeFile "$title" dir) destdir="${destdir//%\{title\}/$replace}" tracknumber="${track%/*}" replace=$(sanitizeFile "$tracknumber" dir) destdir="${destdir//%\{track\}/$replace}" replace=$(sanitizeFile "$year" dir) destdir="${destdir//%\{year\}/$replace}" replace=$(sanitizeFile "$disc" dir) destdir="${destdir//%\{disc\}/$replace}" else destdir+=$(sanitizeFile "${filename%%/*}" dir) part=${filename#*/} while [[ $part =~ / ]] do destdir+="/$(sanitizeFile "${part%%/*}" dir)" part=${part#*/} done fi if ! [ -d "$destdir" ] then mkdir -p "$destdir" fi }