在centOS 5.6中,我需要递归重命名/path中的一系列文件。
需要重命名的文件包含特殊字符组来代替重音字符。我制定了转换表 here . (无论如何,这里使用了什么样的编码?)
我猜测 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.
