• fso查找被删除的文件


    <html>
    <head>
    </head>
    <body>
    源目录:<input id="txtOld" value="F:开发fso"></input>
    新目录:<input id="txtNew"></input>
    对比:<input id="btnCompare" onclick="compareFile()" type="button" value="compare"></input>
    <br/>
    <textarea id="txtContent" style="100%;height:100%"></textarea>
    <script>
    var subfolder;
    var thefile;
    var filename;
    var FSO = new ActiveXObject("Scripting.FileSystemObject");
    //var rootFolder = FSO.getFolder();
    var fileArray = [];
    var newFileObj = {};
    var deleteFileArray = [];
    var oldFolderPath = "", newFolderPath = "";

    function $(id)
    {
    return document.getElementById(id);
    }

    function compareFile()
    {
    fileArray = [];
    deleteFileArray = [];
    oldFolderPath = $("txtOld").value;
    newFolderPath = $("txtNew").value;
    Scan(newFolderPath);
    $("txtContent").value = fileArray.join(" ");
    ScanOldFolder(oldFolderPath );
    // alert(fileArray.length);
    alert(deleteFileArray.length);
    }

    function ScanOldFolder(folderName)
    {
    var folder = FSO.getFolder(folderName);
    if (folder.subFolders.count > 0)
    {
    var fenum = new Enumerator(folder.subFolders);
    for (var i = 0 ; !fenum.atEnd(); fenum.moveNext(),i++){
    //datas.WriteLine("datas["+ i +"] = ""+ fenum.item().Name +"";") ;
    Scan(fenum.item().path);
    }
    }
    //'下面一段将文件夹中的文件路径显示在LABEL上并刷新窗体
    if (folder.Files.count > 0)
    {
    var fenum = new Enumerator(folder.Files);
    for (var i = 0 ; !fenum.atEnd(); fenum.moveNext(),i++){
    //datas.WriteLine("datas["+ i +"] = ""+ fenum.item().Name +"";") ;

    var newPath = fenum.item().path.replace(newFolderPath + "", "");
    if (typeof newFileObj[newPath] != "undefined")
    {
    deleteFileArray.push(newPath);
    }
    }
    }
    }

    function Scan(folderName)
    {
    var folder = FSO.getFolder(folderName);
    if (folder.subFolders.count > 0)
    {
    var fenum = new Enumerator(folder.subFolders);
    for (var i = 0 ; !fenum.atEnd(); fenum.moveNext(),i++){
    //datas.WriteLine("datas["+ i +"] = ""+ fenum.item().Name +"";") ;
    Scan(fenum.item().path);
    }
    }
    //'下面一段将文件夹中的文件路径显示在LABEL上并刷新窗体
    if (folder.Files.count > 0)
    {
    var fenum = new Enumerator(folder.Files);
    for (var i = 0 ; !fenum.atEnd(); fenum.moveNext(),i++){
    //datas.WriteLine("datas["+ i +"] = ""+ fenum.item().Name +"";") ;
    var oldFile = fenum.item().path.replace(oldFolderPath+"", "");
    fileArray.push(oldFile);
    newFileObj[oldFile] = oldFile;
    }
    }
    }
    </script>
    </body>
    </html>

  • 相关阅读:
    感谢一个名叫“祯玥”的姑娘
    下一代互联网
    伤心时要读的三十八句
    任何企业的竞争,归根结底都是智能的竞争
    互联网创业必须过的槛(转)
    钻到牛角尖里面去,想开公司必需知道的奥秘
    重游草堂
    牛根生:我们应该学会“三换思维”
    领导者的感染力和传染力
    幸福是一种心境(转)
  • 原文地址:https://www.cnblogs.com/xjyggd/p/3879597.html
Copyright © 2020-2023  润新知