- @set @n=0//&cscript.exe -e:jscript "%~f0"&exit /b
-
- folder1 = "txt所在文件夹";
- folder2 = "新的文件夹";
- info = "a.txt";
-
- fso = new ActiveXObject("Scripting.FileSystemObject");
- fc = new Enumerator(fso.GetFolder(folder1).files);
- files = [];
- for (i=0; !fc.atEnd(); fc.moveNext()) {
- fp = fc.item().Path;
- if (/\.txt$/i.test(fp)) files[i++] = fp;
- }
- texts = fso.OpenTextFile(info).ReadAll().split("\r\n");
- if (!fso.FolderExists(folder2)) fso.CreateFolder(folder2);
- for (i=0; i<files.length; i++)
- {
- s = fso.OpenTextFile(files[i]).ReadAll();
- rndpos = parseInt(Math.random() * s.length);
- rndtxt = texts[parseInt(Math.random() * texts.length)];
- s = s.slice(0,rndpos) + rndtxt + s.slice(rndpos);
- fso.OpenTextFile(folder2+'\\'+files[i].replace(/^.*\\/,'')).write(s));
- }
复制代码
|