本帖最后由 CrLf 于 2015-1-29 02:18 编辑
这题有意思- 1>1/* : www.bathome.net
- @echo off
- for /f "delims=" %%a in ('dir /a-d /b *.txt^|cscript -nologo -e:jscript "%~0"') do (
- ren %%a
- )
- pause & exit /b
- */
-
- var files = WSH.StdIn.ReadAll().split(/\r?\n/)
-
- for(var i in files){
- var newName = files[i].replace(
- /[零一二三四五六七八九十][O零一二三四五六七八九十百千]*/gm,
- function(match){
- var str = match
- str = str.replace(/[一二三四五六七八九]/g,function(match){return '+'+'空一二三四五六七八九'.search(match)})
- str = str.replace(/([1-9])([十百千])/g,function(match,_1,_2){return _1 + ({'十':'*10','百':'*100','千':'*1000'}[_2])})
- str = str.replace(/^十/,'+10')
- str = str.replace(/(\*10+)0[零O](?!\+\d\1)/g,'$10')
- return (/[^0-9\+\*]/.test(str)) ? match : eval(0+str)
- }
- )
-
- WSH.Echo('"'+files[i]+'" "'+newName+'"')
- }
复制代码
|