Archive: How to delete files except some files?


How to delete files except some files?
Well I found this useful script and was wondering how i could add more then 1 file to keep?
Here's the code:


Section
Push "$INSTDIR\test\"
Push "test1.txt"
Call RmFilesButOne
SectionEnd

Function RmFilesButOne
Exch $R0 ; exclude file
Exch
Exch $R1 ; route dir
Push $R2
Push $R3
Push $R4

FindFirst $R3 $R2 "$R1\*.*"
IfErrors Exit

Top:
StrCmp $R2 "." Next
StrCmp $R2 ".." Next
StrCmp $R2 $R0 Next
IfFileExists "$R1\$R2\*.*" Next
Delete "$R1\$R2"

#Goto Exit ;uncomment this to stop it being recursive

Next:
ClearErrors
FindNext $R3 $R2
IfErrors Exit
Goto Top

Exit:
FindClose $R3

Pop $R3
Pop $R2
Pop $R1
Pop $R0
FunctionEnd


Tested alot of things but it seems like they aint working.. Help ^^ :)?

Just add another `StrCmp $R2 $R0 Next` line replacing $R0 with the filename.


Oh dude!!! Great tnx alot!!!! :D This really helped me ALOT.. tnx again :D