debian - 文件名转码

前言

以前不会用winscp, 上传后的文件名都乱码了. winscp如果没设置,编码是随windows走的。
看到convmv有这个功能,先试一下.
如果文件内容乱码,可以用iconv.

实验

sudo apt-get install convmv

为了保险起见,先备份一下要转换的文件夹

cp -arv ./my_doc ./my_doc.org
// cp命令没有进度指示,都不知道拷贝到啥程度了?

apt-get install gcp
export DISPLAY=:0.0

root@lsserver:/media/data0/ftp_data0# gcp -r ./LsDocument/ ./LsDocument.org
Copying 413.71 GiB   1% |#                                      

本地都拷贝的这么慢,等不及了,杀掉,直接用convmv来转文件名,先用已经拷贝了一些文件的./LsDocument.org目录试试。

convmv帮助

root@lsserver:/media/data0/ftp_data0/LsDocument.org# convmv --help
convmv 1.12 - converts filenames from one encoding to another
Copyright (C) 2003-2008 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 or 3 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
--parsable write a parsable todo list (see man page)
--help     print this help

convmv支持的字符集转换列表

root@lsserver:/media/data0/ftp_data0/LsDocument.org# convmv --list
7bit-jis
AdobeStandardEncoding
AdobeSymbol
AdobeZdingbat
ascii
ascii-ctrl
big5-eten
big5-hkscs
cp1006
cp1026
cp1047
cp1250
cp1251
cp1252
cp1253
cp1254
cp1255
cp1256
cp1257
cp1258
cp37
cp424
cp437
cp500
cp737
cp775
cp850
cp852
cp855
cp856
cp857
cp858
cp860
cp861
cp862
cp863
cp864
cp865
cp866
cp869
cp874
cp875
cp932
cp936
cp949
cp950
dingbats
euc-cn
euc-jp
euc-kr
gb12345-raw
gb2312-raw
gsm0338
hp-roman8
hz
iso-2022-jp
iso-2022-jp-1
iso-2022-kr
iso-8859-1
iso-8859-10
iso-8859-11
iso-8859-13
iso-8859-14
iso-8859-15
iso-8859-16
iso-8859-2
iso-8859-3
iso-8859-4
iso-8859-5
iso-8859-6
iso-8859-7
iso-8859-8
iso-8859-9
iso-ir-165
jis0201-raw
jis0208-raw
jis0212-raw
johab
koi8-f
koi8-r
koi8-u
ksc5601-raw
MacArabic
MacCentralEurRoman
MacChineseSimp
MacChineseTrad
MacCroatian
MacCyrillic
MacDingbats
MacFarsi
MacGreek
MacHebrew
MacIcelandic
MacJapanese
MacKorean
MacRoman
MacRomanian
MacRumanian
MacSami
MacSymbol
MacThai
MacTurkish
MacUkrainian
MIME-B
MIME-Header
MIME-Header-ISO_2022_JP
MIME-Q
nextstep
null
posix-bc
shiftjis
symbol
UCS-2BE
UCS-2LE
UTF-16
UTF-16BE
UTF-16LE
UTF-32
UTF-32BE
UTF-32LE
UTF-7
utf-8-strict
utf8
viscii

先测试一下好使不

convmv -f cp936 -t utf8 --notest -r ./LsDocument.org
好使

开始转换实际的目录
convmv -f cp936 -t utf8 --notest -r ./LsDocument
转换的速度真快啊, 一分钟不到.
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值