<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
  <meta content="text/html;charset=UTF-8" http-equiv="Content-Type">
  <title></title>
</head>
<body bgcolor="#ffffff" text="#000000">
I'd actually skip checking where the links are coming from, and just
pretend any link could be .htm or .html.<br>
<br>
Check for both cases, either using a regex  or just fix the .html cases
first.  So do 2 passes.<br>
<br>
Pass 1: Data.replace('.html', '.php')<br>
Pass 2: Data.replace('.htm','.php')<br>
<br>
I make no claims about what the surrounding code should look like. 
You've gotten a number of responses on that already.<br>
<br>
Cheers,<br>
Cliff<br>
<br>
Sébastien N wrote:
<blockquote
 cite="mid:424c8c5b0708241102q19fc19cape28c1e434994ebd5@mail.gmail.com"
 type="cite">
  <pre wrap="">It's a fact, but still I went on with the solution that overwrites all
the .htm because it's a really big site and about 70-80% of the links
are internal so we'll save time this way.

There's probably a way to analyse if a link is internal or external,
but I needed something fast. But still, I would be interested about
knowing how to do such a thing for the future.

On 8/24/07, J. Cliff Dyer <a class="moz-txt-link-rfc2396E" href="mailto:jcd@sdf.lonestar.org"><jcd@sdf.lonestar.org></a> wrote:
  </pre>
  <blockquote type="cite">
    <pre wrap=""> Tim Williams wrote:
 On 23/08/07, <a class="moz-txt-link-abbreviated" href="mailto:sebzzz@gmail.com">sebzzz@gmail.com</a> <a class="moz-txt-link-rfc2396E" href="mailto:sebzzz@gmail.com"><sebzzz@gmail.com></a> wrote:


 Hi,

I have a bunch of files that have changed from standard htm files to
php files but all the links inside the site are now broken because
they point to the .htm files while they are now .php files.

Does anyone have an idea about how to do a simple script that changes
each .htm in a given file to a .php

Thanks a lot in advance


 Something like:

Infile = open(f_name,'r+')
Data = Infile.read()
InFile.write(Data.replace('.htm','.php'))
Infile.close()

:)

 Yeah, but you'd better make darn sure that *all* links point to .htm files
(including external links), because you could very easily end up pointing to
<a class="moz-txt-link-freetext" href="http://some.othersite.com/index.phpl">http://some.othersite.com/index.phpl</a>

 And that's just no good.


    </pre>
  </blockquote>
  <pre wrap=""><!---->

  </pre>
</blockquote>
<br>
</body>
</html>