回复 32# ww0000
修改了一下,看行不,这个是能显示子目录的,- @if(0)==(0) echo off & dir /b /s /os/a-d "c:\test" | CScript -NoLogo -E:JScript %0 >文件名_大小.txt & pause & exit @end
- var fso=new ActiveXObject("Scripting.FileSystemObject");
- var arr=[], k=1024, m=1048576, g=1073741824;
- while (!WScript.StdIn.AtEndOfStream){
- var name = WScript.StdIn.ReadLine();
- var f =fso.GetFile(name)
- arr.push([name,f.size]);
- };
- arr = arr.sort(function(a,b){ return a[1] - b[1]});
- for (i = 0,len = arr.length; i < len; i++) {
- WSH.Echo(arr[i][0],filesize(arr[i][1]))
- }
- function filesize(size) {
- switch(true){
- case size>g :
- size = (size/g).toFixed(2) + ' GB';
- break;
- case size>m :
- size = (size/m).toFixed(2) + ' MB';
- break;
- case size>k :
- size = (size/k).toFixed(2) + ' KB';
- break;
- default :
- size = size + ' 字节';
- };
- return size;
- }
复制代码
|