Archive: Look for Files containing a certain Word, and if they do, remove them?


Look for Files containing a certain Word, and if they do, remove them?
I'm basically trying to do an Installer for additional content to my software, specifically Language Packs. Because of the way my software works I first have to remove old package files of Languages before I can add a new one. Now what I need is for the Installer to "scan" the folder of where the software was installed and find files that start with a specific prefix.

For example if my User wants to install Spanish language it should work like this:
- Scan the folder for other already existing language packages starting with "lang-" prefix
- May find a file, such as "lang-german.pack"
- (If found such a file, silently remove it)
- Install new file "lang-spanish.pack" to folder

But how do I do this exactly?

I apologize if this is a simple question that already has been answered somewhere, but I am unsure what the term is of what I am looking for and am unable to find a solution because of that.

Thank you very much in advance


It's all in the manual: http://nsis.sourceforge.net/Docs/Chapter4.html

Use FindFirst etc, then either use FileRead etc, or use the macros in wordfunc.nsh (Again, see manual: http://nsis.sourceforge.net/Docs/AppendixE.html )


Thank you MSG, although I ended up solving it another way. I'm now deleting it with a Wildcard ( Delete "$INSTDIR\lang-*.dcp" ) in my Section and then copy the new package file. My installer checks if if and where my product is installed. It seems to work fine :)

Thank you again