Copy link to clipboard
Copied
Hi !
How to delete a folder in which there are both files and subfolders ?
folder.remove() not worked
Copy link to clipboard
Copied
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…
Copy link to clipboard
Copied
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;
if (file instanceof File) {
fName = File(file.fullName)
t = t +'\n'+ fName;
fName.remove()
} else if (file instanceof Folder) {
processFolder(file);
}
}
mFolder.remove()
}