I have a lot of php web files in a folder (1,000+) and all of those files have a common {keyword} what I am needing is a way to replace in a sequence? so this file
web1.php would get keyword1
web2.php would get keyword2
web3.php would get keyword3
the php files are not named web1 just using that as an example.
What I am trying to accomplish is; the bat files looks at the first .php file in the folder and replaces all of the {keyword} occurrences with the first keyword in the csv or text reference file.
So it would look in the web1.php file, find all instances of {keyword} and replace it with the first keyword in the referenced file and then so on for web2.php, web3.php, etc...
I cannot even find something close, help.
batch file to find and replace in sequence
Moderator: DosItHelp
Re: batch file to find and replace in sequence
This may be a little clearer of what I am looking for
I have one folder with thousands of website pages in it.
I have one file with thousands of keywords in it.
The website pages all have the same keyword in it, lets say it is, "Fish".
The keyword file has thousands of different kinds of fish in it not just the word "Fish".
The script would look at page one about fish (call it fish1.php), find all of the "fish" references in that page and replace it with the first keyword in the file.
So it would look at fish1.php find all of the "Fish" keywords and replace them with the first word in the Fish File, "Trout".
Then it moves on to Fish2.php finds the word "Fish" replaces it with the second keyword in the Fish File "Bass" and so on for as many .php files there are in that folder.
I have one folder with thousands of website pages in it.
I have one file with thousands of keywords in it.
The website pages all have the same keyword in it, lets say it is, "Fish".
The keyword file has thousands of different kinds of fish in it not just the word "Fish".
The script would look at page one about fish (call it fish1.php), find all of the "fish" references in that page and replace it with the first keyword in the file.
So it would look at fish1.php find all of the "Fish" keywords and replace them with the first word in the Fish File, "Trout".
Then it moves on to Fish2.php finds the word "Fish" replaces it with the second keyword in the Fish File "Bass" and so on for as many .php files there are in that folder.
Re: batch file to find and replace in sequence
What I would do if having a task like this:
- search for similar tasks and solutions on this forum and the web;
- once found, try to adjust the solution to your case;
- if facing errors, post your script and the errors on this forum
Of course it presumes I'd invest some time and effort in learning new skills and resolving the problem myself. But that's just me...
PS: Using a batch might not be the fastest way for search and replace. Check this: Free Tools to Search and Replace a Word or Phrase Across Multiple Text Files.
- search for similar tasks and solutions on this forum and the web;
- once found, try to adjust the solution to your case;
- if facing errors, post your script and the errors on this forum
Of course it presumes I'd invest some time and effort in learning new skills and resolving the problem myself. But that's just me...
PS: Using a batch might not be the fastest way for search and replace. Check this: Free Tools to Search and Replace a Word or Phrase Across Multiple Text Files.
Last edited by MarioZac on 23 May 2018 01:04, edited 1 time in total.
Re: batch file to find and replace in sequence
For the search and replace part you can use JREPL.BAT
I would recommend to first study and learn how to use JREPL.BAT. After you get familiar with it's usage and syntax then you can think about how to iterate through your php and keywrods files to perform the sequential search and replace on all your php files.
I would recommend to first study and learn how to use JREPL.BAT. After you get familiar with it's usage and syntax then you can think about how to iterate through your php and keywrods files to perform the sequential search and replace on all your php files.