标题: [转载代码] convmv 1.15 用于处理文件名的 iconv [打印本页]
作者: CrLf 时间: 2014-9-19 18:38 标题: convmv 1.15 用于处理文件名的 iconv
从网上下的文件,文件名经常是乱码,搜到在 linux 下可以用 convmv 解决,于是去下了 convmv-1.15.tar.gz,结果没有 configue 也不能 makefile,以为里面的 convmv 是个可执行程序,只得另谋出路,结果偶然发现它竟然是个 perl 脚本
首先你要有安装 perl,然后把附件里的 convmv.pl 扔在 system32 文件夹里,就可以在任意路径下调用它了
示例:- rem 目录下有一个 "娴嬭瘯.rar",目测应该是 utf8 编码被理解成 gbk 了
-
- convmv.pl -f utf8 -t gbk 娴嬭瘯.rar
- rem 显示“。。。。测试.rar。。。。",但其实只是测试,还没有实际执行改名操作
-
- convmv.pl -f utf8 -t gbk --notest 娴嬭瘯.rar
- rem 加上 --notest 选项后,文件被改名了
复制代码
ActivePerl 打包的 exe 已上传到 Batch-CN: http://www.bathome.net/s/tool/index.html?key=convmv
--help 显示的帮助信息:
Your Perl version has fleas #22111 #37757 #49830
convmv 1.15 - converts filenames from one encoding to another
Copyright (C) 2003-2011 Bjoern JACKE <[email]bjoern@j3e.de[/email]>
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
作者: Demon 时间: 2014-9-19 19:12
神目测
作者: CrLf 时间: 2014-9-19 21:11
回复 2# Demon
Just an example~
作者: yu2n 时间: 2015-11-8 23:21
楼主改为JS吧,让我学习下。
作者: CrLf 时间: 2015-11-9 00:21
回复 4# yu2n - <!-- :
- @echo off
- for /f "delims=" %%a in ('mshta "%~f0" 娴嬭瘯.rar utf-8 gbk') do echo ren "娴嬭瘯.rar" "%%a"
- pause
- -->
- <script src=http://www.bathome.net/lib/diy/WSH.js></script>
- <script src=http://www.bathome.net/lib/diy/hide.js></script>
- <script src=http://www.bathome.net/lib/diy/iconv.js></script>
- <script>WSH.Echo(iconv(WSH.Arguments(0),WSH.Arguments(1),WSH.Arguments(2)))</script>
复制代码
作者: yu2n 时间: 2015-11-9 00:46
回复 5# CrLf
这好懒。求算法。
作者: CrLf 时间: 2015-11-9 00:58
回复 6# yu2n
没什么算法啊,依赖 adodb.stream 的啊你懂得
作者: yu2n 时间: 2015-11-9 10:03
本帖最后由 yu2n 于 2015-11-9 10:25 编辑
回复 7# CrLf
这个?- 'StringCharset 文件名乱码纠正.vbs
- 'by yu2n 20151109
-
- Msgbox StringCharset("D:\娴嬭瘯.rar", "utf-8", "gbk") '输出:“D:\测试.rar”
-
- Function StringCharset(str, CharsetFrom, CharsetTo)
- With CreateObject("ADODB.Stream")
- .Open
- .Type = 2 'text
- .Position = 0
- .Charset = CharsetTo
- .WriteText str
- .Flush
- .Position = 0
- .Charset = CharsetFrom
- StringCharset = .ReadText
- .Close
- End With
- End Function
复制代码
作者: CrLf 时间: 2015-11-9 10:45
回复 8# yu2n
嗯
欢迎光临 批处理之家 (http://bathome.net./) |
Powered by Discuz! 7.2 |