- @set @n=0//&cscript.exe -e:jscript "%~f0"&exit /b
-
- file = "a.txt";
- folder = "."; //当前目录
-
- fso = new ActiveXObject("Scripting.FileSystemObject");
- f = fso.GetFolder(folder);
- fc = new Enumerator(f.files);
- files = [];
- for (i=0; !fc.atEnd(); fc.moveNext()) {
- fp = fc.item().Path;
- if(fp.slice(-4).toLowerCase()==".txt") files[i++] = fp;
- }
- texts = fso.OpenTextFile(file).ReadAll().split("\r\n");
- for (i=0; i<files.length; i++)
- {
- a = fso.OpenTextFile(files[i]).ReadAll().split("\r\n");
- a.splice(parseInt(Math.random()*a.length), 0, texts[i]);
- fso.OpenTextFile(files[i]+"~").write(a.join("\r\n"));
- }
复制代码
|