Archive: searching a file for a string and changing that string


searching a file for a string and changing that string....

can this be done? I asked this before and no one answered.

i would like to search for say C:\winamp\test\test and change it to %TargetDir%\test\test where %TargetDir% is the target dir (duh)



CopyFiles C:\Winamp\test\test\*.* %TargetDir%\test\test
Delete C:\Winamp\test\test\*.*
RMDir C:\Winamp\test\test

Messy, but it should work.


I meant to search for a string of text in the file... your solution seems to be moving files themseleves.


I think what he means is inside a data file, he has a string that says "C:\Program Files\MyApp". But if the application is installed in another location, like "D:\MyApp", the prebuilt data file will be wrong. He is wondering if there is a command to to search-and-replace inside a file that you have extracted.

The short answer is no, it can't be done. But a better answer is that yes, you can do it *but* you will have to write a program that does this yourself. I have a search-and-repace program of my own which I use, its about 15kb and runs silently, but it is so heavily dependant on my datafile structure that it would be useless to anyone else. I have a feeling that most people will find it easier to create customized programs like this than to try to find a generic solution.