Join us for SoftSummit 2023. The 20th anniversary of the industry leading software monetization conference. April 18 and 20. Register Now

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
DLee65
Level 13

Modify text in several files

I am wondering if it is possible to just replace part of a string using the text file replacement. We have several .config files that include a value '${TEMP}\SomeFileName.log'. I want to just replace the '${TEMP}\' value with '[INSTALLDIR]' at install time. However, it seems like the search pattern is for the entire string.
[CODE]
e.g., Find What: --> Replace With: [/CODE]

Is there a better way for doing this so that I do not have to identify every .config file and create a new search pattern for each one?

Thank you.
Labels (1)
0 Kudos
4 Replies
MichaelU
Level 12 Flexeran
Level 12 Flexeran

I'm not quite clear what the difficulty you're facing here is; it seems like from what you describe you should be able to search for ${TEMP}\ and replace with [INSTALLDIR] like you say doesn't work. Reading between the lines, do you only want to do this if "${TEMP}\" is followed by certain text that differs in each file you're searching? Like you indicate, I believe that would require separate search patterns for each different suffix.

Alternately, is the problem due to including what looks like the entire element in your search, i.e. could you instead search for ? While this does feel weird, if you control the starting state of the file well enough, it may work in practice.
0 Kudos
DLee65
Level 13

Michael,

Correct, if I simply try to find ${TEMP}\ and replace with [INSTALLDIR] then nothing is changed. Note that I do not have the option for whole word selected in my test. If I include the whole line then the replace works.
All of the examples in the help seem to indicate the need for a whole line as well.

I will try the pattern you suggested to see what happens.
0 Kudos
DLee65
Level 13

I have to apologize. My memory on this behavior was wrong and I just figured out why.

Some of the files contain UNIX style directory notation, e.g.

For files with standard windows notation the replace works correctly with just the find value "${TEMP}\".

I had worked on these back in the spring and my memory is lacking as to why I chose to find and replace a whole string. The only thing I can think of is that I typed something wrong in my earlier tests.
0 Kudos
MichaelU
Level 12 Flexeran
Level 12 Flexeran

No worries; it's always nice when something you remember as hard or impossible turns out to be easy.
0 Kudos