Skip to content
⌘ NSIS Forum Archive

RmDir with wild cards

3 posts

DrDan#

RmDir with wild cards

I need to delete a number of directories which start off with similar names, for example I would like to delete all of the directories

C:\\MyProgram\\Tool.dir.1.data
C:\\MyProgram\\Tool.dir.2.files
C:\\MyProgram\\Tool.dir.3.plugins
C:\\MyProgram\\Tool.dir.4.config
C:\\MyProgram\\Tool.dir.5.data
C:\\MyProgram\\Tool.dir.6.backup
C:\\MyProgram\\Tool.dir.7.files 
If I write

RmDir /r "C:\MyProgram\Tool.dir.*" 
nothing seems to happen, and the error flag doesn't seem to be set. Is there a quick and easy way to do this multiple deletion?
bobics#
Don't think there's anything quick and easy, but you might be able to use this a starting point:

http://nsis.sourceforge.net/Delete_dirs_/_files_in_a_directory_except_one_dir_/_file
DrDan#
Actually this is quite easy...

... and of course I only realised on the way home from work!!!

You can't do it directly, but you can do it with only a few lines of code.

The example for the instruction "FindFirst" (section 4.9.5.9 of the docs) basically does what I need.

It finds files matching a given spec 😁 😁 😁, and all I need to do is change the DetailPrint into a "RMDir /r" and prepend with the full pathname to the directory I am doing the "FindFirst" and "FindNext" in. 😁 😁 😁