Jump to content

Replacing txt in files


ThomasZ
 Share

Recommended Posts

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)

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...