本帖最后由 pcl_test 于 2015-12-5 01:30 编辑
- /*&cls
- @echo off
- dir /b *.txt|cscript -nologo -e:jscript "%~f0"
- pause&exit
- */
-
- var str = [];
- var fso = new ActiveXObject('Scripting.FileSystemObject');
- while (!WScript.StdIn.AtEndOfStream){
- var filename = WScript.StdIn.Readline();
- var txt = fso.OpenTextFile(filename, 1).ReadAll().replace(/(\r?\n)+/g,'\r\n').replace(/\r?\n$/,'').split('\r\n');
- for (var i=0; i<txt.length; i++){
- str.push(txt[i]);
- }
- }
-
- //总行数不足100行,扩充到100行以上
- //while(str.length<100)Array.prototype.push.apply(str, str);
-
- for (var i=1; i<=10000; i++){ //建立10000个文件夹
- if(!fso.FolderExists(i))fso.CreateFolder(i);
- for (var j=1; j<=100; j++){ //每个文件夹建立100个txt文件
- //str.sort(function(a, b){return Math.random()>.5?-1:1});
- var tmp = '';
- for (var k=0; k<100; k++){ //每个txt文件写入100行
- //tmp = tmp+String(str[k])+'\r\n';
- tmp += str[Math.floor(Math.random()*str.length)]+'\r\n';
- }
- var file = '.\\'+i+'\\'+j+'.txt';
- fso.CreateTextFile(file, 2).Write(tmp);
- }
-
- }
-
- WSH.echo('完成');
复制代码
|