2 Replies Latest reply on Oct 7, 2013 1:38 AM by Andy_Bat1

    How to delete a folder with subfolders ?

    Andy_Bat1 Level 1

      Hi !

      How to delete a folder in which there are both files and subfolders ?

       

      folder.remove() not worked

        • 1. Re: How to delete a folder with subfolders ?
          Muppet Mark Level 5

          The guide states that this will only work on empty folders… You will need to loop all the contents removing them when done remove the outer folder…

          • 2. Re: How to delete a folder with subfolders ?
            Andy_Bat1 Level 1

            part of scripts I'm give on this forum :-)

             

             

            var t="";
            var mFolder = Folder('/c/temp/2') ;
            processFolder(mFolder)
            alert(t)
            mFolder.remove()
            
            function processFolder(mFolder) {
                var fileList = mFolder.getFiles()
                    for (var i = 0; i < fileList.length; i++) {
                    var file = fileList[i];
                          if (file instanceof File) {
                          fName = File(file.fullName)
                          t = t +'\n'+ fName;
                          fName.remove()
                    } else if (file instanceof Folder) {
                       processFolder(file);
                    }
               }
                    mFolder.remove()
            }
            
            
            2 people found this helpful