Skip to content
⌘ NSIS Forum Archive

how to replace some special word in many files

10 posts

hustxy#

how to replace some special word in many files

hello,

I need a function to replace some special word with other word in many files.
For example:
replace "$(VERSION)" with "1.0" ,and the word "$(VERSION)" is in many files.It's not easy to change them by hand.🙁



Thanks
Mosestycoon#
Take a look at the archive, there are some functions wich should handle this for you, e.g. http://nsis.sourceforge.net/archive/...ances=0,11,122

But evtl. (somebody to verify please!) you shouldn't use {} brackets as place holders. Think this is some kind of special char. Take for example @@VERSION@@ zu search and replace...

Mo
hustxy#
Thank you

But I want to search files in a directory (and subdirectories) and change the content of the searched files(replace special words).Not just replace word in a string.
kichik#
You can use the following function to find all the files you need:



In the callback function, call the text replacement function.
deguix#
Or this one:

Search File or Directory (Alternative)

Use "about" the same way as the Kichik one...

(I forgot to put it in my signature! Thanks!)
Afrow UK#
There are many text file manipulation functions here:


There are two functions to replace text in files:



-Stu
deguix#
Please, as you (Afrow UK) create much Text Manipulation Pages, create one with the title "Read every byte of a text file" (use "FileRead $var $var2 1", to read each byte), that have a starting and finish point (using FileSeek), the file to read, and to write the result in a string (or in a file if want).

Thanks by the "future help"! 😁
hustxy#
great!
I will search some useful functions in nsis archive. 🙂
Thanks

Richard Xing
Afrow UK#
Originally posted by deguix
Please, as you (Afrow UK) create much Text Manipulation Pages, create one with the title "Read every byte of a text file" (use "FileRead $var $var2 1", to read each byte), that have a starting and finish point (using FileSeek), the file to read, and to write the result in a string (or in a file if want).

Thanks by the "future help"! 😁
I'm not sure how you mean?

-Stu
deguix#
Hehe. I was just a little enthusiastic above normal (refering to "someone to do a function for me")... Maybe is better do not understand...