Archive: Search and replace in files


Search and replace in files
is there a way to search and replace a string in multiple files with a wildcard?

for example i want to replace the string abc with xyz in all *.ini files in a directory and all of its subdirectories

i cant figure out a way to do this...

thx for your help :up:


you can navigate folders with FindFirst and FindNext (see manual) and then use this http://nsis.sourceforge.net/Get_extention_of_file to check if it's a .ini file. To replace string I have no idea on how to do it. maybe this http://nsis.sourceforge.net/ReplaceInFile could be helpful


Originally posted by bennaloz
you can navigate folders with FindFirst and FindNext (see manual) and then use this http://nsis.sourceforge.net/Get_extention_of_file to check if it's a .ini file.
You don't need to get the extension. You can just do FindFirst $0 $1 $INSTDIR\*.ini . This is also clearly shown in the manual: http://nsis.sourceforge.net/Docs/Chapter4.html#4.9.5.13

As for replacing a string, you could use fileread in a loop or something I guess?

Originally posted by MSG
You can just do FindFirst $0 $1 $INSTDIR\*.ini
ehm... =P you're right I forgot it