ThomasZ Posted January 15, 2007 Posted January 15, 2007 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)
jvanegmond Posted January 15, 2007 Posted January 15, 2007 You can use FileGetLongName. For example: FileGetLongName("test.txt") returns it's full path (including C:\Documents...). github.com/jvanegmond
ThomasZ Posted January 15, 2007 Author Posted January 15, 2007 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" ?
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now