Connecting Tech Pros Worldwide Help | Site Map

find and replace in every file under a root folder

 
LinkBack Thread Tools Search this Thread
  #1  
Old July 17th, 2005, 05:41 AM
Cortes
Guest
 
Posts: n/a
Default 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



  #2  
Old July 17th, 2005, 05:41 AM
Justin Koivisto
Guest
 
Posts: n/a
Default 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.
  #3  
Old July 17th, 2005, 05:42 AM
Cortes
Guest
 
Posts: n/a
Default 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]



 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Popular Articles

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over 220,989 network members.