太久没写过脚本了,手好生,写了好久。。。- //Save me as takeline.js
- var arr,sr_arr,subarr,str,key,lastnum;
- var i,j,flag,outStr;
- var fso = new ActiveXObject("Scripting.FileSystemObject");
- var f = fso.OpenTextFile("d:\\test.txt",1,false);
- str = f.ReadAll();
- f.Close();
-
- arr = sr_arr = str.split('\n');
-
- for(i=0; i<arr.length; i++)
- {
- subarr = arr[i].split(' ');
- lastnum = subarr.pop();
- subarr.sort().push(lastnum);
- arr[i] = subarr;
- }
-
- outStr = '';
- for(i=0; i<arr.length; i++)
- {
- flag = 1;
- for(j=0; j<i; j++)
- {
- if(arr[i].toString() == arr[j].toString())
- {
- flag = 0;
- break;
- }
- }
-
- if(flag==1) outStr += sr_arr[i].toString().replace(/\,/g,' ');
- }
-
- f = fso.CreateTextFile("d:\\output.txt", true);
- f.Write(outStr);
- f.Close();
-
- fso = null;
- f = null;
- WScript.Echo('Succeed.');
复制代码
|