views:

103

answers:

1

I have a project that includes 49 folders, each one has a file called index.php

All index.php files are almost the same except for one part that changes depending on the folder it is in.

<?php include_once("/home/bgarch/public_html/galleryheader.html"); ?>
<?php include_once("/home/bgarch/public_html/culture/loadscripts.html"); ?>

</head>
<body>


<div class="header">
    <?php include_once("/home/bgarch/public_html/header.html"); ?>
</div>

<div class="clear"></div>

<div class="displaywrapper">
    <?php include_once("content.html"); ?>
</div></div>    

<div class="clear"></div>

<?php include_once("/home/bgarch/public_html/footer.html"); ?>

In the second line where the above reads: "../culture/.." the word culture is the variable and is different based on the folder it is in.

What I need to do know is do a "Find/Replace all in project" that automatically replaces all the text inside each 'index.php' file with the following"

<?php include_once("http://www.bgarchitect.co.nz/subPage/index.php"); ?>

I have spent the past 2 hours trying to figure out regular expressions to acomplish this but have been unsuccessful so far. Maybe it is not possible to do so?

Anyway, I thought I'd ask a question here in hopes it is in fact much easier than I anticipated. So any help/pointer/hints or tricks are much appreciated.

Thanks for reading, Jannis

+1  A: 

If I understood right, you want to replace the word culture (which is the current directory) with the word subPage?

You can do this with the help of TextMate bundles.

Bundles > Bundle editor > Edit commands, than add a New command. Add this as a command. I think it does what you want. You have to set the input to the command as Entire document and the output to Replace document.

#!/bin/bash

sed "s/"${TM_DIRECTORY##*/}"/theWordYouWanToReplaceTheDirWith/g" | cat
andi
thanks but i must have not explained it clearly. the word 'culture' is the variable. i need to select each index.php and replace its content with the one line rather than the top most code. a search that includes "culture" will not find the other pages that have a different word instead of culture.
Jannis
I just editied my post with what I think is the solution to your problem
andi
Thank you very much!
Jannis
you *could* tick the answer ;)
andi