Php/Perl/Python/Shell脚本根据某些字符的存在重命名文件


Php/Perl/Python/Shell script to rename files based the presence of certain characters

在centOS 5.6中,我需要递归地重命名/path中的一系列文件。

需要重命名的文件包含特殊字符组来代替重音字符。我在这里画出了换算表。(这里到底使用了哪种编码?)

我有一个猜测,perl将是最好的选择,但它也可以是php/python/shell。有人能好心帮我写这个剧本吗?

提前感谢您的帮助。

这是错误编码的UTF-8。使用convmv

>>> print u'Ó'.encode('cp1252').decode('utf-8').encode('cp1252').decode('utf-8')
Ó

$ convmv --nosmart -f utf-8 -t cp1252 Ó
Starting a dry run without changes...
mv "./Ó"    "./Ó"
Ó exists and differs or --replace option missing - skipped
No changes to your files done. Use --notest to finally rename the files.
$ convmv --nosmart -f utf-8 -t cp1252 Ó
Starting a dry run without changes...
mv "./Ó"   "./Ó"
No changes to your files done. Use --notest to finally rename the files.