sanitize filenames
This commit is contained in:
commit
48bf62a84f
43
atom
43
atom
@ -1047,18 +1047,48 @@ copyFile() {
|
|||||||
progressSpin
|
progressSpin
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sanitizeFile() {
|
||||||
|
string="$1"
|
||||||
|
# Filenames can't contain /
|
||||||
|
string="${strings//\// }"
|
||||||
|
if (( ${destinationfat32compat[$destination]} ))
|
||||||
|
then
|
||||||
|
# Filenames can't contain:
|
||||||
|
string=${string//\?/ }
|
||||||
|
string=${string//\\/ }
|
||||||
|
string=${string//</ }
|
||||||
|
string=${string//>/ }
|
||||||
|
string=${string//:/ }
|
||||||
|
string=${string//\*/ }
|
||||||
|
string=${string//|/ }
|
||||||
|
string=${string//\"/ }
|
||||||
|
|
||||||
|
# Filenames can't begin or end with ' '
|
||||||
|
string=${string/#+( )/}
|
||||||
|
string=${string//+( )./.}
|
||||||
|
string=${string//.+( )/.}
|
||||||
|
fi
|
||||||
|
echo "$string"
|
||||||
|
}
|
||||||
|
|
||||||
getDestDir() {
|
getDestDir() {
|
||||||
destdir="${destinationpath[$destination]}/"
|
destdir="${destinationpath[$destination]}/"
|
||||||
if [ -n "${destinationrenamepath[$destination]}" ]
|
if [ -n "${destinationrenamepath[$destination]}" ]
|
||||||
then
|
then
|
||||||
destdir+="${destinationrenamepath[$destination]//%\{album\}/$album}"
|
destdir+="${destinationrenamepath[$destination]//%\{album\}/$album}"
|
||||||
destdir="${destdir//%\{albumartist\}/$albumartist}"
|
replace=$(sanitizeFile "$albumartist")
|
||||||
destdir="${destdir//%\{artist\}/$artist}"
|
destdir="${destdir//%\{albumartist\}/$replace}"
|
||||||
destdir="${destdir//%\{genre\}/$genre}"
|
replace=$(sanitizeFile "$artist")
|
||||||
destdir="${destdir//%\{title\}/$title}"
|
destdir="${destdir//%\{artist\}/$replace}"
|
||||||
|
replace=$(sanitizeFile "$genre")
|
||||||
|
destdir="${destdir//%\{genre\}/$replace}"
|
||||||
|
replace=$(sanitizeFile "$title")
|
||||||
|
destdir="${destdir//%\{title\}/$replace}"
|
||||||
tracknumber="${track%/*}"
|
tracknumber="${track%/*}"
|
||||||
destdir="${destdir//%\{track\}/$tracknumber}"
|
replace=$(sanitizeFile "$tracknumber")
|
||||||
destdir="${destdir//%\{year\}/$year}"
|
destdir="${destdir//%\{track\}/$replace}"
|
||||||
|
replace=$(sanitizeFile "$year")
|
||||||
|
destdir="${destdir//%\{year\}/$replace}"
|
||||||
else
|
else
|
||||||
destdir+="${filename%/*}"
|
destdir+="${filename%/*}"
|
||||||
fi
|
fi
|
||||||
@ -1083,6 +1113,7 @@ getDestFile() {
|
|||||||
destfile="${filename##*/}"
|
destfile="${filename##*/}"
|
||||||
destfile="${destfile%.*}"
|
destfile="${destfile%.*}"
|
||||||
fi
|
fi
|
||||||
|
destfile=$(sanitizeFile "$destfile")
|
||||||
}
|
}
|
||||||
|
|
||||||
encodeFile::mp3() {
|
encodeFile::mp3() {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user