Archive: Recursive Delete


Recursive Delete
Hi,

I have a file system C:\Folder1\Folder2\Folder3\Folder4\Folder5

Folder4 can be a wildcard folder, and under every Folder4 contains a single folder which I want to delete.

Is there a slick way to do this?


yes.

Check FindFirst/FindNext.

Inside a loop that will give you the "Folder4" names, you will delete the Folder5 like this:
RMDir "C:\Folder1\Folder2\Folder3\$1\Folder5"


Doesn't find first find file names and not folder listing?


nevermind it does, thanks!


Note it will also return . and .. which you should exclude.

Stu


..


Just tested this using *.* it picks up both directories and files, I want just directories.


..


It will return both. To filter out directories check if the current file is a directory using IfFileExists path\$1\*.*

Stu


I want only directories:

${If} ${FileExists} "C:\d1\d2\d3\TEST\Data\*.*"
FindFirst $2 $3 "C:\d1\d2\d3\TEST\Data\*.*" #First thing find all directories
loop:
StrCmp $3 "" done
${IfNot} "." == $3
${AndIfNot} ".." == $3

#RM the directory

${EndIf}
FindNext $2 $3
Goto loop
done:
FindClose $2
${Endif}

Where does it need to go? I thought I was already handling this.


See my post: http://forums.winamp.com/showthread.php?t=329007

Stu


Thanks! got it.