- 1>1/* : www.bathome.net
- @echo off
- pushd %~dp0
- call :_Replace
- for /f "delims=" %%i in ('dir /s/b/ad') do (
- pushd %%~si
- call :_Replace
- popd
- )
- pause & exit /b
- :_Replace
- (
- for /f "delims=" %%a in ('dir /a-d /b *.txt^|cscript -nologo -e:jscript "%~s0"') do (
- echo,ren %%a
- ren %%a
- )
- goto :EOF
- )
- */
-
- var files = WSH.StdIn.ReadAll().split(/\r?\n/);
- for(var i in files){
- var nGoOn = /[零一二三四五六七八九十][O零一二三四五六七八九十百千]*/.test(files[i]);
- if (!nGoOn) continue
- 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+'"')
- }
复制代码
|