来个js- folder = "C:\\test2"; //目录路径请用\\
- overWrite = 0; //是否替换原文件
-
- fso = new ActiveXObject("Scripting.FileSystemObject");
- if (!overWrite) {
- if (!fso.FolderExists(folder+'\\new'))
- folder2 = fso.CreateFolder(folder+'\\new').Path;
- else
- folder2 = folder+'\\new';
- } else {
- folder2 = folder;
- }
- e = new Enumerator(fso.GetFolder(folder).Files);
- for (; !e.atEnd(); e.moveNext())
- {
- f = e.item();
- if (f.Name.slice(-3).toLowerCase()=='txt') deal( f.Name );
- }
-
- function deal(file)
- {
- var s='';
- s = fso.OpenTextFile(folder+'\\'+file).ReadAll();
- s=s.replace(/详细说明[\s\S]*/gm, function(ss){return ss.replace(/[\r\n]/g,'');});
- fso.OpenTextFile(folder2+'\\'+file,2,true).Write(s);
- //return(s);
- }
复制代码
|