# to be used with zsh'es glob expansion.
#
# * transliterates everything
+# * replaces non FAT-compatible characters with underscores
# * replaces spaces with underscores
# * lowercases file's extension
# * replaces "_-_" with single dash
# $ torn # assume that it is not autoloaded
# $ zmv "*" '`tornt $f`'
#
+# torna() replaces non FAT-compatible characters with underscores.
+#
# Recursively dive into subdirectories:
# $ zmv -Q "(**/)*(.)" '`torn $f`'
print -- $n
}
+torna() {
+ local n=$1
+ setopt REMATCH_PCRE
+ for i ({1..${#n}}) {
+ [[ ${n[$i]} =~ "[[:ascii:]]" ]] || n[$i]=_
+ [[ ${n[$i]} =~ "[[:print:]]" ]] || n[$i]=_
+ [[ ${n[$i]} =~ "[^,+/:;<=>?[]|]" ]] || n[$i]=_
+ }
+ print -- $n
+}
+
[[ -n $1 ]] || exit
local n=${1:t}
n=`tornm $n`
n=`tornt $n`
+n=`torna $n`
print -- ${1:h}/$n