Connecting Tech Pros Worldwide Forums | Help | Site Map

find and replace in every file under a root folder

Cortes
Guest
 
Posts: n/a
#1: Jul 17 '05
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
Guest
 
Posts: n/a
#2: Jul 17 '05

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<script 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

--
Justin Koivisto - spam@koivi.com
PHP POSTERS: Please use comp.lang.php for PHP related questions,
alt.php* groups are not recommended.
Cortes
Guest
 
Posts: n/a
#3: Jul 17 '05

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<script 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]



Closed Thread


Similar PHP bytes