Skip to main content
boloco
Known Participant
June 24, 2009
Answered

Convert all html files to php files

  • June 24, 2009
  • 1 reply
  • 12759 views

Hi there,

I have hundreds of pages .html in my local folder and I want to convert them to .php.

Is there any way to do this in a single shot instead of going to replace every ".html" with ".php"

Help please.

Thanks!

boloco

This topic has been closed for replies.
Correct answer David_Powers

Exactly!

DwFAQ, I would appreciate you provide me the regular expression so I can try it in the future after I test it.

Actually, I'm with David. I'm just doing it patiently one by one with a some breaks so I don't go too crazy.

Thank you both of you for your input.

This question is for David.

David, can I run without downside html files on a dynamic site?

Thanks!

boloco


Certainly, you can run html files on a dynamic site. There are two possible scenarios:

  • The server is configured to treat .html files as .php files.
  • The .html files don't contain any PHP code.

In the first scenario, the server automatically passes all files to the PHP engine. If you're on shared hosting, your hosting company is unlikely to agree to this, but you can certainly ask.

In the second scenario, you can convert your files to .php as and when you add PHP code to a file. The problem with this approach is that URLs bookmarked by others will break each time you change. When creating a PHP site, I always use .php file name extensions, even if the page isn't dynamic, because it allows me to add PHP code at any stage later on.

1 reply

DwFAQ
Participating Frequently
June 24, 2009

mac or pc?

If Mac use Automator.app just drag the Get Specified Finder Items action into your workflow then click the add button and add the files you want to rename into the list. After that add a Rename Finder Items action and select replace text from the dropdown option list and for find enter .html and for replace enter .php

Run the workflow and you'll have all the selected file extensions that previously had .html extension now renamed to .php

boloco
bolocoAuthor
Known Participant
June 24, 2009

I have a mac.

Thanks for your answer. I'll try it tomorrow. 2 am now. I better do this when I'm freshly awake.

I'll let you know.

Thanks again,

boloco