find and replace in every file under a root folder

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Cortes

    find and replace in every file under a root folder

    Hi all,

    Suppose I want to add 1 single line:

    <script src = "/sample.js" type="text/javascript"></script>

    to every single webpage ( preferrably right after the tag <head>) under the
    root folder called public_html in my server, i.e including all the webpages
    in the subfolders as well. Suppose I have sample.js in public_html as well.

    Can someone please spend some of your precious time to help me out with this
    script.??

    Thanks very much in advance


  • Justin Koivisto

    #2
    Re: find and replace in every file under a root folder

    Cortes wrote:
    [color=blue]
    > Hi all,
    >
    > Suppose I want to add 1 single line:
    >
    > <script src = "/sample.js" type="text/javascript"></script>
    >
    > to every single webpage ( preferrably right after the tag <head>) under the
    > root folder called public_html in my server, i.e including all the webpages
    > in the subfolders as well. Suppose I have sample.js in public_html as well.
    >
    > Can someone please spend some of your precious time to help me out with this
    > script.??[/color]

    The way I'd do it is to use UltraEdit's "Replace In Files" dialog.

    Search for:

    <head>^p

    and replace with:

    <head>^p<scri pt src = "/sample.js" type="text/javascript"></script>^p

    Select the directory, make sure sub direcories option is checked, and
    hit replace.



    --
    Justin Koivisto - spam@koivi.com
    PHP POSTERS: Please use comp.lang.php for PHP related questions,
    alt.php* groups are not recommended.

    Comment

    • Cortes

      #3
      Re: find and replace in every file under a root folder

      Thanks Justin,
      That will work for files in my local machine.

      But I want to make it in a script so that I can execute the script on the
      server-side where my files are. Basically I don't want to download all the
      files, replace, and then upload the updated files again.

      Any ideas pls tell me.
      Thanks alot
      [color=blue]
      > The way I'd do it is to use UltraEdit's "Replace In Files" dialog.
      >
      > Search for:
      >
      > <head>^p
      >
      > and replace with:
      >
      > <head>^p<scri pt src = "/sample.js" type="text/javascript"></script>^p
      >
      > Select the directory, make sure sub direcories option is checked, and
      > hit replace.
      >
      > http://www.ultraedit.com/downloads/index.html
      >[/color]



      Comment

      Working...