0

I think the title speaks for itself. How can I replace multiple strings in multiple files?

For example, I have the following strings:

home.php, blog.php, forums.php, contact.php, etc.

And I want to replace all of them with these, respectively:

home.html, blog.html, forums.html, contact.html, etc.

These are strings in files. They happen to look like file names because they are in HTML hyperlinks. There are hundreds of occurrences and I want to replace them all at once.

I'm using Windows 7 OS. Is there any native Windows command or off-the-shelf software that can do this? I can develop a programmatic solution, e.g., in PHP, because I can have all strings in JSON, XML or array formats, but that's a last resort.

6
  • 2
    Are you talking about replacing strings in files, or in file names? If the latter, you're talking about renaming files, and I suggest that you search this site (and maybe also the web) for that. Oct 20, 2014 at 18:00
  • What Operating System? This is trivial with default *nix tools, but I think you'll have to install something or write up a simple script on Windows.
    – evilsoup
    Oct 20, 2014 at 18:10
  • I'm using Window 7. Oct 20, 2014 at 19:31
  • @G-Man I want to replace the strings in files, not the file names. In my example they look like file names because I'm trying to replace the hyperlinks from HTML. Oct 20, 2014 at 19:32
  • Take a look at this
    – hololeap
    Oct 20, 2014 at 19:47

1 Answer 1

0

A simple array of strings will do if you have any programming skills. Create a for each loop (or for loop throughout the whole array) and recreate the string by dividing the string with '.' as delimiter, so that home.php becomes home and php, replacing second item and then creating string from substrings again. If you only intend to rename php files to html files, you can simply replace every occurence of php with html.

This can be achieved with every scripting and programming language possible, so let us know if you need simple example in language which syntax you're familiar with.

1
  • I personally know how to do this in PHP. I can create a loop, catch all files from directory and open/save the content. I'm looking more for a software, if exists. If it does not exists, then I probably would write the script. ;) Oct 20, 2014 at 19:34

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .