Skip to content
⌘ NSIS Forum Archive

Recursive Delete

12 posts

NSISNUB#

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?
demiller9#
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"
Afrow UK#
It will return both. To filter out directories check if the current file is a directory using IfFileExists path\$1\*.*

Stu
NSISNUB#
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.