Archive: Remove all directories but several


Remove all directories but several
I see from this: http://nsis.sourceforge.net/wiki/Del...one_dir_/_file
how to remove all directories (or files) but one. Does anyone know of a way to remove all directories (or files) but several ?


You can modify Afrow_UK's function to exclude multiple directories or try something like this: http://nsis.sourceforge.net/Uninstal...nstalled_files


Forgive my lack of skill with NSIS scripts, can you (or anyone) bump me in the right direction on what I should edit in Afrow_UK's function?


Have you thought about just manually removing all the stuff you want to? It might mean more code, but you can do that without anything fancier than basic Delete and RMDir commands.

As for the RmDirsButOne function, I hope I'm not breaking etiquette, but watch $R0 (the directory you want to exclude), and specifically, see this line:


StrCmp $R2 $R0 Next

That line tells the function to ignore the directory it is parsing ($R2) if it is the same one that you told it to exclude ($R0).

So you'd want to push all the stuff to exclude and add comparisons for them. I recommend using http://nsis.sourceforge.net/DumpState_plug-in to keep track of your variables and the stack while you are debugging your code.

To anyone: is it ok for me to recommend modifying other people's functions? I thought so, but I'm a newbie and just wanted to make sure.