sanitize filenames
This commit is contained in:
commit
48bf62a84f
43
atom
43
atom
@ -1047,18 +1047,48 @@ copyFile() {
|
||||
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() {
|
||||
destdir="${destinationpath[$destination]}/"
|
||||
if [ -n "${destinationrenamepath[$destination]}" ]
|
||||
then
|
||||
destdir+="${destinationrenamepath[$destination]//%\{album\}/$album}"
|
||||
destdir="${destdir//%\{albumartist\}/$albumartist}"
|
||||
destdir="${destdir//%\{artist\}/$artist}"
|
||||
destdir="${destdir//%\{genre\}/$genre}"
|
||||
destdir="${destdir//%\{title\}/$title}"
|
||||
replace=$(sanitizeFile "$albumartist")
|
||||
destdir="${destdir//%\{albumartist\}/$replace}"
|
||||
replace=$(sanitizeFile "$artist")
|
||||
destdir="${destdir//%\{artist\}/$replace}"
|
||||
replace=$(sanitizeFile "$genre")
|
||||
destdir="${destdir//%\{genre\}/$replace}"
|
||||
replace=$(sanitizeFile "$title")
|
||||
destdir="${destdir//%\{title\}/$replace}"
|
||||
tracknumber="${track%/*}"
|
||||
destdir="${destdir//%\{track\}/$tracknumber}"
|
||||
destdir="${destdir//%\{year\}/$year}"
|
||||
replace=$(sanitizeFile "$tracknumber")
|
||||
destdir="${destdir//%\{track\}/$replace}"
|
||||
replace=$(sanitizeFile "$year")
|
||||
destdir="${destdir//%\{year\}/$replace}"
|
||||
else
|
||||
destdir+="${filename%/*}"
|
||||
fi
|
||||
@ -1083,6 +1113,7 @@ getDestFile() {
|
||||
destfile="${filename##*/}"
|
||||
destfile="${destfile%.*}"
|
||||
fi
|
||||
destfile=$(sanitizeFile "$destfile")
|
||||
}
|
||||
|
||||
encodeFile::mp3() {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user