Script or tool needed: Multiple file, Multiple string - Search and Replace

Status
Not open for further replies.

ImagesAndWords

StayblCam.com
Nov 7, 2006
2,326
90
0
Scottsdale, Arizona
www.stayblcam.com
Hey guys,
I'm looking for a script or utility that is capable of some advanced search and replace work based on a list of search/replace values.

To explain what I mean;

- I have a two-column file (csv or txt) containing strings in a format like this:

Code:
aaaaa, bbbbb
ccccc, ddddd
eeeee, fffff
ggggg, hhhhh
iiiii, jjjjj
kkkkk, lllll
The 1st column is the string to be found.
The 2nd column is the new string to replace the old with (so "aaaaa" should be replaced by "bbbbb")

- I have a set of files where one contains "aaaaa", another contains "ccccc", another cointans "eeeee", etc.

- I want to be able to find the file that has "aaaaa" and replace it with "bbbbb". Then find the file that contains "ccccc" and replace it with "ddddd"

I could probably code something like this in Perl with some creative use of regexp. but I don't wanna waste my time if there is a tool/script for this job already in existence.

Do you know of any?

Thanks in advance!


wf%20boobs.jpg
 


simple if you have excel there is a glitch with excel and notepad whist works in you favor. if you put something in two baxes in excel copy them and past the 2 boxes in notepad you will see a gap between them highlight the gap and copy then go to your list and have i replace your comma with a comma and then past what you copied after the comma in the replace with box and hit replace all. once replaced copay all and past into excel and it will put everything into 2 seperate columns. Then just use the one your want
 
simple if you have excel there is a glitch with excel and notepad whist works in you favor. if you put something in two baxes in excel copy them and past the 2 boxes in notepad you will see a gap between them highlight the gap and copy then go to your list and have i replace your comma with a comma and then past what you copied after the comma in the replace with box and hit replace all. once replaced copay all and past into excel and it will put everything into 2 seperate columns. Then just use the one your want

I don't think you quite understand what I was asking. I'm not looking to modify the the csv file with the two columns. I could do that easy in UltraEdit. That file is just for lookup and to tell the tool what to look for - and what to replace with.

I have a set of files (hundreds of them) where one contains "aaaaa". In that file, "aaaaa" should be replaced by "bbbbb". As specified in the .csv file.
 
i can do it using regex super fast and easy. You may have to be more forthcoming with details

Alright.. well, basically the input would be:

- the .csv file, let's call it OLDNEW.csv
This is really nothing but a plain text file, where each line consists of:

Code:
OldStringToFind, NewStringToReplaceIt
- a path to the folder where all the files are located, e.g. c:\files
It could contain any set of text-based files like:

boringfile.txt
longfile.txt
smallfile.txt
failfile.txt

The files could be over-written with the result so there's no need to generate new files / new filenames.

So now - if there's a line in OLDNEW.csv that says;

DPsucks, WFowns

Then, we'd wanna find the file that contains "DPsucks". We find that "longfile.txt" does - so we replace "DPsucks" with "WFowns" in that file and save it to itself, overwriting the old one.

Then move on to the next line in OLDNEW.csv, and so on...

Makes sense? :)
 
Status
Not open for further replies.