Code: Select all
Directory
Datax
Datay
Directory
xyz
abc
Directory
Bla bla
Bla bla
Etc.
Code: Select all
Directory1
Datax
Datay
Directory2
xyz
abc
Directory3
Bla bla
Bla bla
Etc.
I used the following:
1. First load the textfile as a variable.
2. Use RegExReplace to count the number of occurences of the string
3. Then I used StrReplace to find the string 'Directory' and replace it with 'Directory'[incrementing number].
4. Write the result to a new file.
Here is the code:
Code: Select all
FileRead, myvar, inputfile.txt
dummy := RegExReplace(myvar, "Directory", "Directory", OutputVarCount) ; OutputVarCount contains the number of replacements that occurred
newvar := StrReplace(myvar, "Directory", "Directory" []OutputVarCount)
FileAppend, %newvar%, outputfile.txt