diff --git a/atom b/atom index 7620990..caed8a0 100755 --- a/atom +++ b/atom @@ -1089,6 +1089,7 @@ copyFile() { } sanitizeFile() { + shopt -s extglob string="$1" # Filenames can't contain / string="${string//\// }" @@ -1106,6 +1107,7 @@ sanitizeFile() { # Filenames can't begin or end with ' ' string=${string/#+( )/} + string=${string/%+( )/} string=${string//+( )./.} string=${string//.+( )/.} fi @@ -1133,7 +1135,14 @@ getDestDir() { replace=$(sanitizeFile "$disc") destdir="${destdir//%\{disc\}/$replace}" else - destdir+="${filename%/*}" + destdir+=(sanitizeFile "${filename%%/*}") + part="${filename#*/}/" + while : + do + destdir+="/$(sanitizeFile "${part%%/*}")" + part=${part#*/} + [ -z "$part" ] && break + done fi if ! [ -d "$destdir" ] then