- //&cls&dir /a-d/b "小说.txt"|cscript -nologo -e:jscript "%~f0"&pause&exit
-
- var fso = new ActiveXObject('Scripting.FileSystemObject'), s='';
- while(!WSH.StdIn.AtEndOfStream){
- var line = WSH.StdIn.ReadLine(), fname, fext;
- line.replace(/(.+)(\.[^\.]+)/, function($0,$1,$2){fname=$1;fext=$2});
- if(!fso.FolderExists(fname))fso.CreateFolder(fname);
- var text = fso.OpenTextFile(line, 1).ReadAll();
- //指定字数量和分割的标点符号
- var m = text.match(/[\s\S]{200,}?([。!?!\?]”|[。!?!\?\n])|[\s\S]+$/g);
- s+='---------------------'+line+'---------------------\r\n';
- WSH.echo('开始分割'+line+'……');
- for(var i=0;i<m.length;i++){
- var newfname = fname+'_'+(i+1)+fext;
- fso.CreateTextFile(fname+'\\'+newfname, 2).Write(m[i]);
- s+=newfname+' '+m[i].length+'个字符\r\n';
- }
- WSH.echo('分割完成!共分成'+i+'个文件\r\n');s+='\r\n';
- }
- fso.CreateTextFile('分割记录.log', 2).Write(s);
- WSH.echo('Done');
复制代码
|