Friday, August 15, 2008

FreeBSD| 文件名转码工具convmv

文件名转码工具convmv - wzhy's blog - 我博客~我作主~~

Linux中文文件名转码工具 convmv

2008年7月23日(Wednesday) 15点58分 作者: netdragon 天气: 心情: 一般

   由于更改系统字符集导致了所有中文文件名都变为了乱码,不用着急,可以用convmv来搞定。


convmv 1.10 - converts filenames from one encoding to another
Copyright (C) 2003-2006 Bjoern JACKE <bjoern@j3e.de>

This program comes with ABSOLUTELY NO WARRANTY; it may be copied or modified
under the terms of the GNU General Public License version 2 as published by
the Free Software Foundation.

 USAGE: convmv [options] FILE(S)
-f enc     encoding *from* which should be converted
-t enc     encoding *to* which should be converted
-r         recursively go through directories
-i         interactive mode (ask for each action)
--nfc      target files will be normalization form C for UTF-8 (Linux etc.)
--nfd      target files will be normalization form D for UTF-8 (OS X etc.)
--qfrom    be quiet about the "from" of a rename (if it screws up your terminal e.g.)
--qto      be quiet about the "to" of a rename (if it screws up your terminal e.g.)
--exec c   execute command instead of rename (use #1 and #2 and see man page)
--list     list all available encodings
--lowmem   keep memory footprint low (see man page)
--nosmart  ignore if files already seem to be UTF-8 and convert if posible
--notest   actually do rename the files
--replace  will replace files if they are equal
--unescape convert%20ugly%20escape%20sequences
--upper    turn to upper case
--lower    turn to lower case
--help     print this help


Command:
shell$>  convmv -f gbk -t utf-8 *.lrc --notest
mv "./�ܴ��� - ��įɳ����.lrc"    "./周传雄 - 寂寞沙洲冷.lrc"
mv "./�ܱ�ٻ - ���ĺ�����.lrc"    "./周冰倩 - 真的好想你.lrc"
mv "./���ľ� - ����.lrc"    "./满文军 - 懂你.lrc"
mv "./�»��� - Ʈѩ.lrc"    "./陈慧娴 - 飘雪.lrc"
mv "./���� - ����.lrc"    "./彭羚 - 囚鸟.lrc"

OK!

 


wzhy 于 2008-3-4,21:15 
归类于:GNU/Linux  Tags:.

于转换windows分区拷文件过来可能出现文件名乱码,例如

convmv -f utf8 -t cp936 --notest *

convmv -f cp936 -t utf8 --notest -r --nosmart <要转换的文件夹或文件>

另外,对于一些在windows下自己刻录的光盘在读取中文文件名时会出现乱码的情况,解决的方法很简单,打开终端,输入sudo gedit /etc/fstab

打开fstab文件,找到
/dev/scd0 /media/cdrom0 udf,iso9660 user,noauto 0 0

(就是修改挂载分区属性的那个),修改为
/dev/scd0 /media/cdrom0 udf,iso9660 user,noauto,iocharset=utf8 0 0

保存后将光盘重新插入到光驱就可以了。

No comments: