Find/ replace within many php files at once??

7 replies
Is there any way to find/ replace the text within many php files at once? I want to make theme-wide changes to a wordpress theme. So, I need a program that will search through a the theme folder, through the internal folders to all the php files and preform the find and replace function.

Any Help?
#files #find or #php #replace
  • Profile picture of the author theIMgeek
    Most software made for web programming will have this function. I use Netbeans IDE. Also Notepad++ is very popular. Both are free.

    -Ryan
    Signature
    FREE WSO: Protect and Automatically Deliver Your Digital Products

    Ask the Internet Marketing Geek
    <-- Happy to help with technical challenges
    MiniSiteMaker.org <-- Free software to make your mini-sites fast and easy
    {{ DiscussionBoard.errors[2024757].message }}
    • Profile picture of the author mojojuju
      If you've got shell access, you can do this in the blink of an eye like this:


      Code:
      find ./ -type f | xargs sed -i 's/original_text/replacement_text/g'
      Running that in a directory will recursively replace all occurrences of 'original_text' with 'replacement_text' .
      Signature

      :)

      {{ DiscussionBoard.errors[2024780].message }}
  • Profile picture of the author Mike Adams
    Its primarily for wordpress templates and plugins. All the files are in a folder, and I want to do a find and replace for all the files in each folder without having to open each file manually. I could do it easily if I only had to do one file but you know most themes and plugins have 23, 30, 50+ files.

    @RJP will those programs work with what I'm trying to do?
    Signature
    P.S. If you found my post useful, please click the "Thanks" button below...
    {{ DiscussionBoard.errors[2025667].message }}
    • Profile picture of the author Christopher Airey
      Yes, both responses will satisfy what you need. The second is the easier way if you're familiar with shell (and have access), but an IDE/Notepad++ is easier if you aren't familiar with SSH.
      {{ DiscussionBoard.errors[2025892].message }}
  • {{ DiscussionBoard.errors[2026004].message }}
  • Profile picture of the author growclicks
    The obvious- Dreamweaver. Just add the folder in the 'My Sites' folder and search through all the files in your site.
    {{ DiscussionBoard.errors[2028708].message }}
  • Profile picture of the author Bellthorpe
    Any decent text editor will do that. I use UltraEdit, but there of course are others.
    {{ DiscussionBoard.errors[2029078].message }}

Trending Topics