问题
I'm quiet new to bash scripting, and I would like to convert recursively all my filenames in folder from UTF-8 encoding to ASCII (which is very portable encoding).
I think that iconv command would be of some use:
iconv -f utf8 -t ascii ...
But I'm not sure how to use it exactly.
At best the bash script should print some hint about it's progress, like name of file it just converted.
Thank you very much.
回答1:
find /my/path -type f > utf8list
iconv utf8list > asciilist
i=1
for file in $(cat utf8list); do
newname=$(head -$i asciilist | tail -1 | tr -d '\n')
#mv $file $newname
echo "mv $file $newname"
let i++
done
来源:https://stackoverflow.com/questions/9929441/how-to-recursively-convert-all-filenames-in-folder-subtree-from-utf-8-to-ascii-i