格式化某个目录下的所有源代码的js代码

var fso,Folder;
var WshShell = new ActiveXObject("WScript.Shell");
var re = new RegExp(".*/.[c|h]$","ig");

fso = new ActiveXObject("Scripting.FileSystemObject");
dir="H://yourhome";

dealfile(fso,dir);

function dealfile(fso,folderspec)
{
    var f, fc, s,fn;
    var cmd = "G://astyle//astyle --style=ansi "
    f = fso.GetFolder(folderspec);
    ff = new Enumerator(f.files);
    s = "";
    for (; !ff.atEnd(); ff.moveNext())
    {
     fn = ff.item();
     if( re.test(fn))
     {
      s += ff.item()+" ";
     }
    }
    if (s != "")
    {
     cmd += s;
     //WScript.Echo(cmd);
     WshShell.exec(cmd);
    }
    fc = new Enumerator(f.SubFolders);
    for (; !fc.atEnd(); fc.moveNext())
    {
     dealfile(fso,fc.item());
    }

你可能感兴趣的:(c,function,cmd)