Sign in to follow this  
Followers 0
ThomasZ

Replacing txt in files

3 posts in this topic

Hello,

i am using the following script which replaces the text inside a file. It works fine so far. However i would like that i don't have to insert the full path. Idealy i would just make a .exe and run it directly in the path where the file is in which i have the text. Is there any way ?

Another problem: I have to use line breaks in the replace text like

text1 = a + b + c;

text2 = c*b;

Thanks in advance !

Here is my code, based on the AutoIT help:

#include <File.au3>

$find = "//End of settings"

$replace = "AFTER + \n test for /n break"

$filename = "C:\Dokumente und Einstellungen\Thomas\Eigene Dateien\autoit tests\test.txt"

$retval = _ReplaceStringInFile($filename,$find,$replace)

if $retval = -1 then

msgbox(0, "ERROR", "The pattern could not be replaced in file: " & $filename & " Error: " & @error)

exit

else

endif

$msg = FileRead($filename, 1000)

Share this post


Link to post
Share on other sites



thanks.

important for me is even the line break.

Can i define anywhere that it should only replace any exact defined text like "TestText_1" but not "TestText_2" ?

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0